Jump to content

Setting polar in LISP AND VBA but still...


Recommended Posts

Posted

... it isn't set!

 

In my mnl file i got the following variables set:

(setvar "POLARANG" 90)

(setvar "AUTOSNAP" 63)

 

With VBA (wich automaticly runs when autocad is started) I do it again!:

ThisDrawing.SetVariable POLARANG, 90

ThisDrawing.SetVariable AUTOSNAP, 63

 

You should think that my polar now ON and the angle is set to 90 degrees except the polar angle is 116.620156177409!?!?!

 

I think this value comes from rad? But I don't care... I want to preset that polar is ON and the angle is 90! If I correct it manually the value 116.xx disappears and 90 is set, it works fine then. When I close autocad and restart it. The value 116.xx is back as polarangle!

 

Someone has an idea to fix it??

Posted

Its probably your "units" conflicting with the setvar when units are set to degrees then keyboard 90 else if radians then 1.57.....

 

In this case I would bet the setvar polarang is always in radians. Lots of stuff must always be in radians when programming it ignores the UNITS settings.

Posted

Thnx!

 

For a correct value for RAD I've done the following:

 

    Dim Pi As Double
   Pi = Atn(1) * 4
   Ang = Pi / 2
   ThisDrawing.SetVariable "POLARANG", Ang

  • 1 year later...
Posted

was an easy solution ever found for this pain is the a** issue???

Posted

Further to above Erratic Always!!! work in radians not degrees then no problems this has been with Autocad since day dot, also the angle set it to say 0 via units up, no its still to right.

 

90=1.570796 or set a variable pi90 etc generally only need 4 0 1.570796 3.141593 3.92699

 

This is the easy solution.

Posted

I won't deny that you just passed along an easy fix, but it may has well have been in Chinese as it doesn't help me much. But thank you.

Posted

What are you trying to do erratic?

 

When setting the POLARANG System variable programmatically, it will take a value in Radians, so you will need to convert your Degrees to Radians.

 

Here is a simple function to help you:

 

(defun SetPolarAng ( x )
   (setvar 'POLARANG (* pi (/ x 180.)))
)

 

Call with angle in degrees, eg;

 

(SetPolarAng 90.0)

Posted

Majority of dwg's are at square angles so you only need to know the 4 radian values 0 1.570796 3.141593 3.92699 = 0 90 180 270 then as per LEE just use a Degrees to radians DTR, backwards = RTD these are old lisps been around for ever and would normally be located in your startup lisp so they are ready to use in any other program.

 

(defun dtr (a)
(* pi (/ a 180.0))
)
;
(defun rtd (a)
(/ (* a 180.0) pi)
)

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