Jump to content

Creating Line at an angle


priyanka_mehta

Recommended Posts

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 →

Please help !!!

 

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

 

http://www.cadtutor.net/forum/showthread.php?p=340889#post340889

 

 

Thanks and Regards,

Priyanka

Link to comment
Share on other sites

As far as I understand you need something like this:

 

Function drawLineNorth(basePt As Variant, lineLen As Double, angDeg As Double) As AcadLine
   Dim angRad As Double
   angRad = ThisDrawing.Utility.AngleToReal(angDeg + 90, acDegrees)
   
   Dim line As AcadLine
   
   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
   
   Set line = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
   line.Move pt1, basePt
   line.Rotate basePt, angRad
   line.Update
   Set drawLineNorth = line
End Function


Sub TryLineNorth()
   Dim L As AcadLine
   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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...