PDA

View Full Version : Creating Line at an angle

priyanka_mehta
9th Jul 2010, 12:11 pm
Hi all,

I need to create a line with specific length and angle using VBA.

I am using Utility.PolarPoint method for the same
but i need to set 0° North clockwise for my angles.

It is not following the drawing units if i change them manually. It is by default using East Anticlockwise (3' 0 Clock position).

Is there a way to set the drawing unit to north clockwise so that when i create a line at an angle of 0° through VBA it should appear like ↑ and not like →

I have tried this solution that i received by posting the thread at incorrect sub forum but it didnt help

Thanks and Regards,
Priyanka

SEANT
9th Jul 2010, 12:33 pm
Modifying ANGBASE/ANGDIR may not apply at the level which VBA operates. It isn’t too hard to do that mathematically, however.

Joro--
9th Jul 2010, 07:42 pm
As far as I understand you need something like this:

Function drawLineNorth(basePt As Variant, lineLen As Double, angDeg As Double) As AcadLine
angRad = ThisDrawing.Utility.AngleToReal(angDeg + 90, acDegrees)

Dim pt1(2) As Double
pt1(0) = 0
pt1(1) = 0
pt1(2) = 0

Dim pt2(2) As Double
pt2(0) = lineLen
pt2(1) = 0
pt2(2) = 0

line.Move pt1, basePt
line.Update
Set drawLineNorth = line
End Function

Sub TryLineNorth()
Dim basePt(2) As Double
basePt(0) = 1
basePt(1) = 1
basePt(2) = 0

Set L = drawLineNorth(basePt, 3, 45)
L.Update
End Sub
is that OK for you?

priyanka_mehta
12th Jul 2010, 08:03 am
Thanks Joro. But I took Seant's suggestion and I mathematically rotated by using (theta*(-1)+ PI/2) where PI = Atn(1)*4. So it takes a 90 degree rotation which is the difference between arithmetic and geographic coordinates and autocad by default takes arithmetic coordinate system where as i wanted it in latter.

Thanks a lot !!!
Regards,
Priyanka