Grasshopper

algorithmic modeling for Rhino

Hi, I do not understand what is happening when I try to mirror a polyline. i have a 'profileA' and I want to mirror it to get 'profileB'. when i do the following both profiles end up in the mirrored position. Why is that? How could I make a copy of the first profile and then freely manipulate it without effecting the original?

Dim profileA As New Polyline(listofpoints)

Dim profileB As New Polyline

profileB = profileA

Dim Xmirrorprofile As transform = transform.Mirror(centerpoint, normalvector) 

profileB.Transform(Xmirrorprofile)

i had to go around it by defining the profileB with the same list of points, but I would like to understand what is happening in the first case for future application...

Dim profileB As New Polyline(listofpoints)

Any help appretiated.

Stepan

Views: 835

Replies to This Discussion

Polyline is a Reference Type (better known as a "class"). Therefore when you say:

profileB = profileA

both variables now reference the same polyline. Therefore if you change one, you also change the other. You need to make a specific duplicate of the polyline if you want to distinct instances.

Dim profileA As New Polyline(listofpoints)

Dim profileB As New Polyline(listofpoints)

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Ok, I was thinking that something like that was happening. 

Would there be a way how to duplicate an instance without recreating it from scratch - points?

For example if I input a curve into my VB from rhino and then I would want to duplicate it.

(AsVal inputcurve as curve)

dim curve1 as new curve = ? (...copy of inputcurve)

dim curve2 as new curve = ? (...copy of inputcurve)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service