algorithmic modeling for Rhino
Hi all,
sorry if it's a stupid question ... I'm confused.
Is there a clean, generic way to duplicate RhinoCommon structure instances ?
In particular I'm talking about Rhino.Geometry structures.
Since in Python assigning a structure instance to a variable does not create a new instance, I'm looking for an easy way to duplicate that instance.
Some structures have what I might call copy-constructors:
I can build a new Point3d from another Point3d, same for Plane etc ...
Some other structures lack that. There is no constructor to build a Line from a Line, or an Arc from an Arc, etc. Nor are there Duplicate() methods for them.
What should I do to duplicate an Arc ?
Thanks
emilio
Tags:
TryGetArc(Arc, Double), TryGetCircle(Circle), TryGetEllipse(Ellipse).
I hope this answers your question.
Cordiali saluti,
FF
Hi Florian,
many thanks for your clear explanation !
Indeed I copied the arc by an instruction like:
newarc = Rhino.Geometry.ArcCurve( oldarc ).Arc
I'm glad to see that it's also what you suggest. :) ( I wasn't sure about it )
But I'm not glad to learn that there is no better way ... ;)
... Having to create a class instance to copy a structure instance feels somewhat strange ...
OK, problem solved.
Thanks again !
Saluti
emilio
Emilio,
if oldarc is of type Rhino.Geometry.Arc, you can just assign it directly and a copy will be made:
Arc newArc = oldArc;
oldArc.Radius = 5;
at this point newArc will still have the old radius.
--
David Rutten
david@mcneel.com
Tirol, Austria
Hi David,
please correct me if I'm wrong.
I think that copy by assignment for structures works fine in VB and C#, but I just learned (the hard way ...) that Python works differently.
It seems that structure instances are copied by reference, just like class instances ...
Thanks for replying !
emilio
I suppose that a generic Python specific approach would be to use the copy module. See attached file. Also, really great post Florian.
That's awesome...these kind of things are the reason people should do python instead of vb/c# ;-)
Thanks Anders
Careful now, no worries ;)
Hi Anders,
nice idea ! Works fine. :)
Thanks a lot !
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson.
Powered by