Getting the "circle steps" ???
-
Now I need to get the "steps" a circle is build of (standard is 24) but it can be changed dirung a session and then resets to 24 again when SU is restarted.
How can I "get" this "step" as a number and use it in my code ?
-
A circle is a Sketchup::ArcCurve instance.
All classes in Ruby inherit methods from their superclass (and it's superclass, and the superclass of that, .. and so on, back to
Object
[which has moduleKernel
, mixed into it.])So ...
Sketchup::ArcCurve.superclass %(#008000)[>> Sketchup::Curve]
Looking at the API for Sketchup::Curve, we find:
-
By the Way.. the actual default is hard-coded and cannot be changed by the user (manually, or easily by code.)
This is one of the common feature requests that SketchUp does not yet have.The "current" value of Curve segments is kept internally by SketchUp.. and is not yet exposed via the Ruby API. (Nor is it saved in the defaults in the Registry/Plist.)
Access to it is one of the API feature requests that has been logged. -
Argh ... thx anyway Dan !
-
You can of course change the segments of an Arc/Circle, in code as you make it.
I recall someone once wrote a PC only script that auto-loaded and ran as Sketchup started [you could also use an observer to ensure the setting applied to new SKP files in that session].
It ran some winscript shortcut=C] to make a circle inside a temp-group and did various key-strokes for segments/radius/etc [36s/1 etc] - then it immediately erased the circle-temp-group.
The new segment number is then used that session for all new circles... -
Is there a way to batch change in a script?
I.e. I run a script and the first action is to change all arcs and circle to a number of segment such that each segment is smaller than xxx.
-
Yup.. that's what I meant by "not easily."
-
@michaelv said:
Is there a way to batch change in a script?
I.e. I run a script and the first action is to change all arcs and circle to a number of segment such that each segment is smaller than xxx.
You may be able to iterate the Curve's edges (
curve.edges.each
) and split each one at it's midpoint (edge.split
) .. don't know. I never tried it.Otherwise, .. you would have to recreate them I think. Get each one's start point, end point, center, angle, and make a new one to replace it. Delete the old one.
-
Just tried it at the console. It does indeed split each edge. BUT ... the new vertices remain at the center of the chords. (They do not move out to the circumference, like they do if you use the native "DivideTool.")
And I do not see an API method equivalent for that tool.
-
My "ArcCurve-set_segments" tool lets you change the segments of selected Arcs, just as you could using Enity Info on each one... you are also bound by the same limitations - e.g. you can't change the segments if the Arc is part of a 3d object...
e.g. In the Ruby Console typing
changearcsegments 360
makes selected [eligible] Circles have 360 segments... -
@tig said:
My "ArcCurve-set_segments" tool lets you change the segments of selected Arcs, just as you could using Enity Info on each one... you are also bound by the same limitations - e.g. you can't change the segments if the Arc is part of a 3d object...
Argh, that's exactly what I was envisioning to do (a 3D object application). Well it makes sense that it cannot be done on the volume by changing the segments of the generating geometry. I didn't think of that.
Thanks for the answers.
Advertisement