I have a circle that I would like to move ‘Z’ direction along the Current UCS. The Current UCS can be in any 3d plane.
The code that I have only moves the circle 5 units up along the WCS.
Dim Zp As New Vector3d(0, 0, 5) Zp.TransformBy(ed.CurrentUserCoordinateSystem) myCircle.TransformBy(Matrix3d.Displacement(Zp))
Please help. Thank you.
-J
Hi,
The Vector3d.transformBy() method is a Function (in VB). It returns a new Vector3d object (this is due to the fact Vectors (as Points) are immutable structures).
In your code you do not get the transformed vector and Zp remains (0, 0, 5).
Try:
Dim wcsZp As New Vector3d(0, 0, 5) Dim ucsZp = wcsZp.TransformBy(ed.CurrentUserCoordinateSystem) myCircle.TransformBy(Matrix3d.Displacement(ucsZp))
or simply:
Dim Zp As New Vector3d(0, 0, 5) Zp = Zp.TransformBy(ed.CurrentUserCoordinateSystem) myCircle.TransformBy(Matrix3d.Displacement(Zp))
Thank you very much Gilles.
I am surprised that I did not get an error or warning in VS for : Zp.TransformBy(ed.CurrentUserCoordinateSystem)
VS won't display any warning for this kind of unused function returned value with mostly imperative language as VB or C#.
It's the same thing when you use BlockTableRecord.AppendEntity() method which returns an ObjectId and you don't care about it.
ObjectId id = btr.AppendEntity(ent);
or:
btr.AppendEntity(ent);
With F# which encourages functional programming VS displays a warning if you don't bind the returned value to a symbol. In this case you have to use the 'ignore' keyword.
With AppendEntity
let id = btr.AppendEntity(ent)
or:
btr.AppendEntity(ent) |> ignore