Author Topic: 'Extender' plugin (autocad-like 'extend' and 'trim' features)  (Read 31306 times)

Offline jk

  • Wookie
  • ****
  • Posts: 265
    • View Profile
'Extender' plugin (autocad-like 'extend' and 'trim' features)
« on: September 24, 2016, 14:06:09 pm »
Hello.

One of features I've missed most in CamBam's CAD is the ability to extend line/arc up to the intersection with some object. Think of 'extend' command of Autocad.

So here is the quick and dirty plugin designed to mimic it.

How to use:
1) Run 'Extender' from the Plugins menu
2) Select boundary objects (any objects except points and surfaces wil do)
3) (Repeatedly) click on lines or arcs to be extended

Clicked line/arc should extend from the clicked side up to intersection with the nearest boundary object.
Line or arc segments of polyline may be extended too, in some cases mutating the polyline in a funny way.

Should be very useful for preparing imported dxfs to machining, say, move one edge of pocket boundary to get a sharp corners.

Version 2.0 adds the trim functionality. Hold shift while clicking on lines to perform trim instead of extend.

Source code:
https://github.com/jkmnt/extender

PS Plugin is experimental and may fail in some cases, e.g. for lines with nonzero Z. Or may not )

---
Version 2.0.0
* Added the trim functionality

Version 1.2
  Changed toolbar icon

Version 1.1
  Added pre-extend step to select boundaries
  Text resources are wrapped for translation
  Selection of extendable object is non-snapping for easy aiming
  Toolbar "icon" and Ctrl+Plus shortcut
 
« Last Edit: April 10, 2017, 19:42:50 pm by jk »

Offline tau

  • Storm Trooper
  • ***
  • Posts: 169
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #1 on: September 24, 2016, 14:40:42 pm »
jk, Thx for this nice extension to the CB toolset!

Works like a charm! ;D

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 4436
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #2 on: September 24, 2016, 16:17:50 pm »
Just did a simple test and it works as described.  Very nice tool.  

Critique:
1.  Its a little finicky to select the line to extend because it seems to use the snap to function which is often the grid and not the line, but its workable.  
2.  It would be nice to be able to terminate the plugin by selecting another tool or menu option instead of just by hitting the ESC key.  

Overall:  It is a useful tool as is.  
« Last Edit: September 24, 2016, 23:25:33 pm by Bob La Londe »
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: 5248
  • Made in England
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #3 on: September 24, 2016, 18:00:29 pm »
Good plugin and nicely coded in proper OOP style, unlike the hybrid 'ANSI C / C#' style I use  :D and can't see me even getting out of that way either, too old to change.

Bob,
I see what you mean about terminating the plugin but I think hitting 'Esc' is consistent with other CamBam functionality.

Jasper,
I used ILSpy to save the code as a Visual Studio project but some parts do not export in a way that the compiler likes. Can you tell me how your original code code looks compared to this ILSpy saved method ?

private void replace_arc(Arc dst, Polyline src)
      {
         Arc arc = (Arc)src.ToPrimitives()[0];
         dst.set_Point(arc.get_Point());
         dst.set_Start(arc.get_Start());
         dst.set_Sweep(arc.get_Sweep());
         dst.set_Radius(arc.get_Radius());
         dst.Update();
      }

Also to keep David and non English speaking users happy,  it might be a good idea to include translation in this and future plugins, there are plenty of examples and threads about it.

It just needs this include at the strart,

         include CamBam.Util;

and for example,

    CamBam.ThisApplication.AddLogMessage("No valid boundaries selected");

becomes

         CamBam.ThisApplication.AddLogMessage(TextTranslation.Translate("No valid boundaries selected"));


keep up the good work !


« Last Edit: September 25, 2016, 06:23:05 am by EddyCurrent »
Filmed in Supermarionation

Offline SquibLoad

  • Ewok
  • *
  • Posts: 8
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #4 on: September 24, 2016, 18:22:56 pm »
Very nice, I've been hoping for this feature for quite a while. 
This is a great addition!

Please don't take these as criticisms, but a few suggestions occurred to me while using:


Allow selecting plugin tool first, and then select lines to be extended.


Allow serial selection of pairs, for example, select line A and line B to be extended, perform extension, release selections, then select line C and line D, extend them, repeat, etc.


Extend two selected lines to meet that don't currently have an extended crossing point.  this would be useful for changing a corner fillet, for example. Sample work flow- explode, delete fillet, select extender, rejoin lines, re-fillet with different radius.


Thanks for this plugin!
John B




Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5248
  • Made in England
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #5 on: September 24, 2016, 18:28:48 pm »
Maybe it should follow the same user interface method as Cambam's Trim function ? having said that I've no real problem with it as it stands.
Filmed in Supermarionation

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8938
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #6 on: September 24, 2016, 20:16:28 pm »
Thank you, JK!  Welcome to the club of CB plugin-ers!

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3353
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #7 on: September 24, 2016, 23:48:16 pm »
Nice addition. Thank you JK. ;)
My 2¢

Win11, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, 4th Axis, Endurance Laser.

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7371
    • View Profile
    • Cambam V1.0 French Doc
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #8 on: September 25, 2016, 00:55:52 am »
Hello,

Very nice ! and it works very well, good addition !

Quote
1.  Its a little finicky to select the line to extend because it seems to use the snap to function which is often the grid and not the line, but its workable.  

I do not have this pb, I can select any or both of the 2 snap mode, grid or/and object, or nothing (I use the snap toolbar, but it works also with the menu) all mode works with this plugin.

Quote
Also to keep David and non English speaking users happy,  it might be a good idea to include translation in this and future plugins, there are plenty of examples and threads about it.

Lol ; but remember to not translate the menu item itself (the "Extender" text that appears in the Plugin menu) ; it is automatically translated by CamBam.

++
David

Edit: and it works on alpha version too 8) ... I like also the ability to detect multiple intersections with a same object. One request ? ... a toolbar icone, because certainly I will use this tool frequently !
« Last Edit: September 25, 2016, 01:15:03 am by dh42 »

Offline Garyhlucas

  • CNC Jedi
  • *****
  • Posts: 1459
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #9 on: September 25, 2016, 02:51:09 am »
I haven't tried the plug-in yet but I am sure I will find it useful as I brought up this function being needed on the forum a long time ago!

Thanks,
Gary H. Lucas

Have you read my blog?
 http://a-little-business.blogspot.com/

Offline jk

  • Wookie
  • ****
  • Posts: 265
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #10 on: September 25, 2016, 09:55:02 am »
Thank you all for replies. Think I'm not the only one to miss this feature )

Quote
Critique:
1.  Its a little finicky to select the line to extend because it seems to use the snap to function which is often the grid and not the line, but its workable. 
the snap to is getting in the way sometimes, yes.
If somebody knows a suitable EditMode without snap, I may use it.
Now I use PointSelectEditMode (adopted this part of code from the dh42's Filler-Chamfer plugin)
which snaps. Alternatively, I may try to disable the snaps and restore then afterward.

Quote
I used ILSpy to save the code as a Visual Studio project but some parts do not export in a way that the compiler likes. Can you tell me how your original code code looks compared to this ILSpy saved method ?

Also to keep David and non English speaking users happy,  it might be a good idea to include translation in this and future plugins, there are plenty of examples and threads about it.
See the full source code on github (link in updated first post).
Good idea to wrap text resources in Translate(). Easy and may be useful )

Quote
Allow selecting plugin tool first, and then select lines to be extended.
I think I'll add 'Select boundaries' step followed by 'Select object to extend', this way it will be a little more consistent with the native 'Trim'.

Quote
One request ? ... a toolbar icone, because certainly I will use this tool frequently !
Hmm, is there a user way to do a custom toolbars I don't know ? Or you mean plugin should insert itself there programmatically ? )

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8938
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #11 on: September 25, 2016, 10:47:23 am »
"Hmm, is there a user way to do a custom toolbars I don't know ? Or you mean plugin should insert itself there programmatically ?"

----
The tool should insert a button in the existing toolbar.  There's still plenty of room. 

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3353
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #12 on: September 25, 2016, 11:07:51 am »
Not steal the thread but I still could use the dash/dot lines now and then... ;)
 
My 2¢

Win11, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, 4th Axis, Endurance Laser.

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5248
  • Made in England
    • View Profile
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #13 on: September 25, 2016, 11:33:06 am »
Personally I'm not a fan of github, I can't imagine I'll ever use it for my own projects.
Filmed in Supermarionation

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 4436
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: 'Extender' plugin (autocad-like 'extend' feature)
« Reply #14 on: September 25, 2016, 14:45:27 pm »
I would note that while I had some critique I think this is a good plug-in that does what is intended on the first release.  I will use it.  I doubt I'll ever have the time to learn to program for CamBam, and I appreciate those of you who do. 
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