Author Topic: In Place Resize plugin  (Read 1847 times)

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4854
    • View Profile
In Place Resize plugin
« on: September 22, 2020, 20:18:02 pm »
As a result of this thread; https://cambamcnc.com/forum/index.php?topic=8720.msg69458#msg69458

I thought about a plugin to address some of the issues.
The plugin will resize all selected objects and will ensure the selected "Base point" stays in place following the resize.
It measures the current distance between two points then prompts the user for a final target distance, scale factor is calculated then the objects are scaled accordingly.

Ctrl + Z will Undo the resize if required.

Please download and install the plugin
then download the attached sample cb file and open it
now follow these instructions.

It's best to have "snap to grid" off, the plugin will automatically enable "snap to object" while it is working.

In this example we require the distance between points A and B to be 118mm

1. Select the objects, (circle and shape)
2. Edit->Transform->In Place Resize
3. "Select Base point (A)", this is a point on the objects that will remain in place following the resize
4. choose the centre of the small circle as "Base point"
5. "Select Reference point (B)", this is another point on the objects that is the required distance from Base point
6. Choose the right most tip of the object.
7. A form will appear showing the current length between Base point (A) and Reference point (B)
8. Type the required length into "Target Length" box, enter 118
9. click the OK button
10 the objects have been resized and the Base point has not moved
11. Use Tools->Measure to check the new distance between A and B

Obviously the Centroid of an object or objects can be selected as the "Base point"

Edit:

Version 2 attached, also works with bitmap entities.
« Last Edit: June 05, 2021, 21:01:39 pm by EddyCurrent »
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6682
    • View Profile
    • Cambam V1.0 French Doc
Re: In Place Resize plugin
« Reply #1 on: September 22, 2020, 20:47:47 pm »
Hello

Very nice job and useful plugin ! thanks !!

I often thought to add something like this to the NumMove plugin as a new resize tab .... but I never did it ...  :-*

++
David

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 4156
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: In Place Resize plugin
« Reply #2 on: September 22, 2020, 22:15:29 pm »
Resize with a selectable anchor point is standard in ViaCAD which would address most issues.  VC also allows the origin or overall center as one of the selectable points. 
Getting started on CNC?  In or passing through my area?
If I have the time I'll be glad to show you a little in my shop. 

Some Stuff I Make with CamBam
http://www.CNCMOLDS.com

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4854
    • View Profile
Re: In Place Resize plugin
« Reply #3 on: September 24, 2020, 06:37:25 am »
@David, Attached are the source project files for version 1.0.

If you want to incorporate it into your NumMove plugin that would be fine with me.
« Last Edit: September 24, 2020, 06:41:10 am by EddyCurrent »
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6682
    • View Profile
    • Cambam V1.0 French Doc
Re: In Place Resize plugin
« Reply #4 on: September 24, 2020, 17:14:24 pm »
Hello

thanks ;)

++
David

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6682
    • View Profile
    • Cambam V1.0 French Doc
Re: In Place Resize plugin
« Reply #5 on: June 03, 2021, 14:23:13 pm »
Hello Eddy

I just tried to use this plugin to resize a Bitmap object, and it seems to have no effect with this object ...  ;)

Edit:
a workaround

https://www.screencast.com/t/4F5piK836o

++
David
« Last Edit: June 03, 2021, 14:56:31 pm by dh42 »

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4854
    • View Profile
Re: In Place Resize plugin
« Reply #6 on: June 03, 2021, 15:44:12 pm »
David,

You are correct, I did not consider bitmaps at the time.
I like your alternative method and time permitting I might try to update the plugin.
Made in England

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4854
    • View Profile
Re: In Place Resize plugin
« Reply #7 on: June 04, 2021, 20:03:01 pm »
David,

I see why it's not working with a bitmap.

The code goes like this;

Code: [Select]
// do resize with Params.basePoint staying in place
            foreach (Entity entity in view.SelectedEntities)
            {
                entity.Transform.Translate(-Params.basePoint.X, -Params.basePoint.Y, -Params.basePoint.Z);
                entity.Transform.Scale(Params.scaleFactor);
                entity.Transform.Translate(Params.basePoint.X, Params.basePoint.Y, Params.basePoint.Z);
                entity.ApplyTransformation();
                entity.Transform = Matrix4x4F.Identity;
           
                entity.Update();
                view.Selection.RefreshExtrema();
                CamBamUI.MainUI.ObjectProperties.Refresh();
            }

The problem is with line, entity.Transform = Matrix4x4F.Identity;

It seems to work for everything except a bitmap.
My intention was to do the required transforms then set that to "identity" to reset the matrix.

EDIT:

I knew the answer but forgot it  ???

It should say;

 if (entity.ApplyTransformation()) entity.Transform = Matrix4x4F.Identity;


« Last Edit: June 04, 2021, 20:26:02 pm by EddyCurrent »
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6682
    • View Profile
    • Cambam V1.0 French Doc
Re: In Place Resize plugin
« Reply #8 on: June 04, 2021, 20:35:11 pm »
Hello

Yes, in manual mode, it seems that Edit/transform/apply transformation has no effect on a bitmap (the matrix is no recalculated), so I assume that when you "identity" it's equal to "reset" the matrix to his default state.

I guess that the bitmap object must be left "as is" after a transformation ... so the lines

entity.ApplyTransformation();
entity.Transform = Matrix4x4F.Identity;

must be skipped if the object is a bitmap object ..

.... maybe  ;D

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4854
    • View Profile
Re: In Place Resize plugin
« Reply #9 on: June 04, 2021, 20:42:45 pm »
David,

I think you are correct.

Even using, if (entity.ApplyTransformation()) entity.Transform = Matrix4x4F.Identity;

The bitmap transform matrix is still left "as is" rather than being set to "identity"

If it is set to "identity" it reverts back to it's original state.

Made in England

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4854
    • View Profile
Re: In Place Resize plugin
« Reply #10 on: June 04, 2021, 20:46:11 pm »
Version 2 of the plugin attached to the first post in this thread.

It also works with bitmaps.
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6682
    • View Profile
    • Cambam V1.0 French Doc
Re: In Place Resize plugin
« Reply #11 on: June 04, 2021, 20:57:20 pm »
Quote
Even using, if (entity.ApplyTransformation()) entity.Transform = Matrix4x4F.Identity;

Note sure, but I think that entity.ApplyTransformation() only return the state of the matrix (true if in modified state, false if the matrix is already in "identity" state), but this don't say if the object can be "identity" or not.

I searched for a CanIdentity() function (like the CanConvert() function) ... but can't find one.

Quote
Version 2 of the plugin attached to the first post in this thread.

Thanks !!  ;D

++
David

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6682
    • View Profile
    • Cambam V1.0 French Doc
Re: In Place Resize plugin
« Reply #12 on: June 04, 2021, 21:03:47 pm »
Works well ! (but it is not translatable)  ;D

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4854
    • View Profile
Re: In Place Resize plugin
« Reply #13 on: June 05, 2021, 09:37:35 am »
David,

I have replaced the v2 file in the first post, please see if the translation works now.
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6682
    • View Profile
    • Cambam V1.0 French Doc
Re: In Place Resize plugin
« Reply #14 on: June 05, 2021, 19:10:47 pm »
Hello

Ok for all, except for the Cancel button that is not translatable.

Also, there is a typo on the title (in place resuze)



++
David