.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Moving a Circle Z direction along the Current UCS

3 REPLIES 3
Reply
Message 1 of 4
junoj
476 Views, 3 Replies

Moving a Circle Z direction along the Current UCS

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

 

 

 

3 REPLIES 3
Message 2 of 4
_gile
in reply to: junoj

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))

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4
junoj
in reply to: junoj

Thank you very much Gilles.

 

I am surprised that I did not get an error or warning in VS for : Zp.TransformBy(ed.CurrentUserCoordinateSystem)

Message 4 of 4
_gile
in reply to: junoj

VS won't display any warning for this kind of unused function returned value with mostly imperative language as VB or C#.

 

ignoreCs.png

 

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.

 

ignoreFs.png

 

With AppendEntity

let id = btr.AppendEntity(ent)

or:

btr.AppendEntity(ent) |> ignore

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost