Author Topic: Set Angle Direction  (Read 451 times)

0 Members and 1 Guest are viewing this topic.

Nima2018

  • Newt
  • Posts: 28
Set Angle Direction
« on: February 07, 2019, 02:35:54 AM »
Hi

I want to set the angles to the north and clockwise to get the azimuths.
How do I do this in my application by code?
I do not want to do this in the AutoCAD environment, through the menus and windows of units and direction .
Normally when using :
Code: [Select]
double teta=myLine.Angle;
the angle of the line is obtained from the east and counterclockwise direction.

n.yuan

  • Bull Frog
  • Posts: 277
Re: Set Angle Direction
« Reply #1 on: February 07, 2019, 10:21:17 AM »
I assume that you want the angle base and angle direction to be North and Clockwise, which may or may not be the same as AutoCAD is set up in its current session, WHEN your code runs. AFTER your code runs, you want AutoCAD keeps its original angle base and direction. Not surprising at all, you use system variable "ANGBASE" and "ANGDIR" to do it.

You would have code like

Dim aBase As Double
Dim aDir As Integer

''Save variables' current value
aBase=ThisDrawing.GetSysVariable("ANGBASE")
aDir=ThisDrawing.GetSysVariable("ANGDIR")

'' Set variables as needed
ThisDrawing.SetSysVariable("ANGBASE", 3.1415926/2)
ThisDrawing.SetSysVariable("ANGDIR", 1)

On Error Resume Next

DoWork

If err.Number<>0 Then
  '' handle possible error
End If

'' Restore the variables back to their original value
ThisDrawing.SetSysVariable("ANGBASE", aBase)
ThisDrawing.SetSysVariable("ANGDIR", aDir)


Private Sub DoWork()
  '' Do whatever
End Sub

Nima2018

  • Newt
  • Posts: 28
Re: Set Angle Direction
« Reply #2 on: February 07, 2019, 12:24:34 PM »
Dear n.yuan

Thank you for your advice .
It was very elaborate and perfect .