[Plugin] Recurve

[Plugin] Recurve

Postby Diggsey » Fri Apr 22, 2011 4:22 pm

Recurve v1.5

This plugin converts a sequence of edges into a curve. Useful when performing an operation has exploded a curve which you want to stay as a curve. Also includes options to quickly select edges which could potentially form a curve, and filter the selection to only include specific types of edges, faces or groups.

Simply download the attached script to your plugins folder to try it out.



Instructions:

- Quickly select edges to be recurved
Select a single edge from the edges to be made into a curve and choose "Recurve -> Select Curve" or "Recurve -> Select Curve (Planar)" from the context menu. If the curve exists in a single plane, "Select Curve (Planar)" is more likely to find the correct sequence of edges. The command works by following a sequence of edges which don't change direction sharply.

- Recurve a sequence of edges
Select all the edges which make up the curve and choose "Recurve -> Recurve Edges" from the context menu. The edges should be instantly replaced with a curve.

- Filter the current selection
From the context menu choose "Select Only -> " followed by your filter choice. The selection will be updated to only include those entities matching the filter.

- Reverse a curve
Select the curves you want to be reversed and choose "Recurve -> Reverse Curve" from the context menu. There will be no visible change, but the curves will be reversed.

Update v1.1
- Improved curve selection
Curve selection now uses the directions of edges to help decide which edges should be selected.

- Simplified code
Refactored the code so that it's easier to maintain, and runs more efficiently.

- Improved context menu handler
For large selections, the context menu handler will run in constant time.

- Fixed divided curve bug
For curves which intersect hard edges, the old version had a bug which could cause the resulting curve to be divided up at other places. This same bug is present in Fredo6's Tools On Surface plugin when drawing a curved shape over a hard edge.

- Added reverse curve command
Does what it says on the tin!

Update v1.2
- Removed recursion
None of the algorithms now use recursion so there is no danger of stack overflow.

- Selection saved
Reverse curve now updates the selection to include all of the new reversed curves.

Update v1.3
- Moved recurve commands into submenu
All commands are now in either the "Select Only -> " or "Recurve -> " submenus.

- Can now recurve curves
Curves will be automatically exploded if recurve is run on them.

- Can now select curves including existing curves
The select curve menu item will show up when the selection is a curve.

- Added combo commands
There are commands to quickly select and recurve at the same time, in both normal and planar versions.

Update v1.4
- Now works with SketchUp 6

Update v1.5
- Fixed bug with faces touching the curve at only a corner
Some code needs to run for each face touching the curve. Previously it used the edges in the curve to find the faces. Now it uses the vertices to find the faces.
0
Last edited by Diggsey on Sat Apr 30, 2011 2:09 pm, edited 8 times in total.

Diggsey 
 

Re: [Plugin] Recurve

Postby wyatt » Fri Apr 22, 2011 4:27 pm

This looks useful. Is it possible to add a feature to set the direction of the curve? This would have great application for Sketchy Physics which is often confused by the proper start and end of a curve.
0

wyatt 
 

Re: [Plugin] Recurve

Postby kyyu » Sat Apr 23, 2011 1:13 am

@Diggsey, thanks for the plugin.

@Wyatt, there is a plugin by Fredo6 (called RevertCurve) that will reverse a curve's direction: viewtopic.php?t=25710
0

kyyu 
 

Re: [Plugin] Recurve

Postby wyatt » Sat Apr 23, 2011 3:43 am

Awesome. I didn't know about that plugin. Probably would have saved me hours last week. :shock:
0

wyatt 
 

Re: [Plugin] Recurve

Postby thomthom » Sat Apr 23, 2011 1:27 pm

Welcome to the forum and thanks for sharing. Very nice introduction. :)

Iæd just like to point out a post I made about context menu handlers: viewtopic.php?f=180&t=31788
Basically, iterating over every entity in a selection can add a significant lag when you have a larger selection set and it should be avoided so that SketchUp's context menu doesn't end up lagging several seconds.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Recurve

Postby Diggsey » Sat Apr 23, 2011 1:36 pm

Thanks for the heads up about context menu handlers. I'll change it in the next update. I've added the ability to reverse curves but I'm still trying to fix some bugs. Somehow the curves are being split up which is weird...
0

Diggsey 
 

Re: [Plugin] Recurve

Postby rock1 » Sat Apr 23, 2011 6:11 pm

does this perform the same function as weld?
0

rock1 
 

Re: [Plugin] Recurve

Postby thomthom » Sat Apr 23, 2011 7:45 pm

rock1 wrote:does this perform the same function as weld?

yes and much more.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Recurve

Postby Diggsey » Sun Apr 24, 2011 2:10 am

Just updated the plugin to v1.1. See the first post for details and download.
0

Diggsey 
 

Re: [Plugin] Recurve

Postby dedmin » Sun Apr 24, 2011 7:54 am

I'm getting a bugsplat when trying to reverse a curve with more segments - like arc with 120 segments.
0

dedmin 
 

Re: [Plugin] Recurve

Postby Diggsey » Sun Apr 24, 2011 1:00 pm

I've fixed the bug for large numbers of edges.

The algorithm used to use recursion to find a route through the edges and that cause a stack overflow. Now all the algorithms work using simple loops.

See the first post for v1.2
0

Diggsey 
 

Re: [Plugin] Recurve

Postby dedmin » Sun Apr 24, 2011 1:12 pm

Diggsey wrote:I've fixed the bug for large numbers of edges.

The algorithm used to use recursion to find a route through the edges and that cause a stack overflow. Now all the algorithms work using simple loops.

See the first post for v1.2

Working fine now! Thanks!
0

dedmin 
 

Re: [Plugin] Recurve

Postby dedmin » Sun Apr 24, 2011 1:15 pm

I noticed reversing an arc makes it curve - it is not arc anymore. Is that the way it works?
0

dedmin 
 

Re: [Plugin] Recurve

Postby Diggsey » Sun Apr 24, 2011 1:36 pm

Yes, currently it only makes curves not arcs. The reverse curve command basically explodes the curve and then calls recurve on it in the opposite direction, so the arc information is lost in the process. I could try changing recurve so that it detects if the sequence of edges makes a perfect arc.

The problem is, there are some arcs that are almost impossible to recreate. If you create an arc and then draw a line through it, you get two arcs, neither of which can be drawn with the arc tool. Even changing the number of segments in them will change their shape irreversibly.

Alternatively, if there are SketchUp features which you need to use and only work on arcs, I could make them work with all curves.
0

Diggsey 
 

Re: [Plugin] Recurve

Postby dedmin » Sun Apr 24, 2011 1:50 pm

I see - thanks for the explanation. Just noticed this and wanted to be sure it is not a bug.
0

dedmin 
 

Re: [Plugin] Recurve

Postby thomthom » Sun Apr 24, 2011 2:09 pm

Diggsey wrote:Yes, currently it only makes curves not arcs. The reverse curve command basically explodes the curve and then calls recurve on it in the opposite direction, so the arc information is lost in the process. I could try changing recurve so that it detects if the sequence of edges makes a perfect arc.

why not just detect if you are exploding an arc?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Recurve

Postby Diggsey » Sun Apr 24, 2011 2:31 pm

That doesn't help solve the problem I mentioned though. The only way I know of to create an arc in sketchup is with Entities.add_arc, which is functionally equivalent to the arc tool. Arcs created by dividing another arc in two cannot be made this way. I would have to know the exact sequence of events which happened to create the arc in the first place to recreate it in the opposite direction.
0

Diggsey 
 

Re: [Plugin] Recurve

Postby utiler » Mon Apr 25, 2011 3:29 pm

dedmin wrote:I see - thanks for the explanation. Just noticed this and wanted to be sure it is not a bug.

What is the difference? I thought an arc was a curve..... :shock:
0
purpose/expression/purpose/....
User avatar
utiler 
Top SketchUcator
 

Re: [Plugin] Recurve

Postby TIG » Mon Apr 25, 2011 7:17 pm

An 'Arc' IS a 'Curve'... BUT a 'Curve' is NOT necessarily an 'Arc'...
Also remember that 'Circles' [a special 'Arc' that's 360 degrees] and 'Polygons' are also types of 'Curve' - as is any bound-set-of-edges that has been made as a 'Curve' [e.g. a Bezier Curve or a 'Welded' Curve made from edges]...........
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Recurve

Postby jeff hammond » Mon Apr 25, 2011 9:47 pm

probably my oldest plugin request has finally happened :D
weld with no dialog boxes.


a few suggestions (if you're open to it, of course)

say i have two lines with an arc fillet connecting them and i'd like to make them all a single polyline (ie- something i do a lot with weld.rb), the recurve function won't work (or it doesn't appear in the context menu).. in order to recurve that scenario, i have to first explode the arc (or any polyline segments) prior to being able to recurve.

it'd be nice if i could weld a combination of edges/lines with curves (or arcs,polylines,etc.. what ever you want to call them :D) using recurve.



there's also a bit of weirdness in there as far as 'select curve' goes.. using the same scenario as above, if i right click on the arc fillet then the 'select curve' option doesn't show up.. but, if i right-click on either of the lines then 'select curve' does show up and if i choose it, all parts including the arc will be selected.


and taking that a step further, it'd be nice to have an option for 'select curve then recurve' (or whatever) so i could select a bunch of broken segments and weld them together in one operation..

ultimately, this will definitely replace weld for me as my W shortcut and the last request would be assigned to ⇧W .


thanks a bunch!
0
dotdotdot
User avatar
jeff hammond 
Global Moderator
 

Re: [Plugin] Recurve

Postby kyyu » Mon Apr 25, 2011 11:40 pm

Jeff Hammond wrote:probably my oldest plugin request has finally happened :D
weld with no dialog boxes.

I never liked the 2 dialog boxes, either. Always answered "no". So I commented they out, in my modified version. 8-)
0

kyyu 
 

Re: [Plugin] Recurve

Postby mmscanlo » Tue Apr 26, 2011 1:04 am

Super helpful, thanks for sharing :)
0

mmscanlo 
 

Re: [Plugin] Recurve

Postby utiler » Tue Apr 26, 2011 1:46 am

Thanks TIG.... :thumb:
0
purpose/expression/purpose/....
User avatar
utiler 
Top SketchUcator
 

Re: [Plugin] Recurve

Postby Diggsey » Tue Apr 26, 2011 11:54 am

Just updated the first post with update 1.3. It includes the changes suggested by Jeff.
0

Diggsey 
 

Re: [Plugin] Recurve

Postby mitcorb » Tue Apr 26, 2011 1:07 pm

Thanks, Diggsey:
I just downloaded it to give it a try.
0
I take the slow, deliberate approach in my aimless wandering.
User avatar
mitcorb 
Top SketchUcator
 

Re: [Plugin] Recurve

Postby Rich O Brien » Tue Apr 26, 2011 1:22 pm

Really like this plugin.

One suggestion is that the context-menu 'Select Only' is changed as it is already used by Thomthom's Selection Tools. So I've 2 'Select Only' options.

Maybe all menu items under 'Recurve'
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] Recurve

Postby Diggsey » Tue Apr 26, 2011 1:38 pm

I've uploaded a new version. It behaves the same as the last version, but if you open it in notepad you can change the line:
RECURVE_ALL_UNDER_RECURVE_MENU = false
to:
RECURVE_ALL_UNDER_RECURVE_MENU = true

That will put the Select Only menu under the Recurve menu.
0

Diggsey 
 

Re: [Plugin] Recurve

Postby Rich O Brien » Tue Apr 26, 2011 1:41 pm

Thank you :thumb:
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] Recurve

Postby jeff hammond » Tue Apr 26, 2011 3:14 pm

Diggsey wrote:Just updated the first post with update 1.3. It includes the changes suggested by Jeff.



wow! that's great.
it's been added to my shortcuts and has replaced my most used ruby.. so long good friend (weld) :D

[btw - the 'select curve and recurve' (⇧W) seems like magic :D]

thanks so much!
0
dotdotdot
User avatar
jeff hammond 
Global Moderator
 

Re: [Plugin] Recurve

Postby Ben Ritter » Wed Apr 27, 2011 3:58 pm

Thank you Diggsey.
0

Ben Ritter 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: Carto, Google Bot and 12 guests

Visit our sponsors: