Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Polar Autolisp Command

Status
Not open for further replies.

jdmcclung

Mechanical
Aug 16, 2002
7
I am trying to write a command to draw a formed channel. I am using the polar command to find the points around the channel.
ex. (setq pt2 (polar pt1 (dtr 180) 5))
The problem I am comming across is that the two angles of the channel will not always be 90 deg. For instance if the two angles are 90 the top leg will end up in a 0 deg direction according to the UCS. However if the two angles were 135 deg the top leg would be in a 90 deg direction. So in short the second angle is based off the first angle. I tried to use the angbase command to rotate the ucs, but found that the polar command works off of the WCS; which can not be edited. Is there another command similiar to polar that will work with the ucs? or some other way to base the second angle off the first. Thank you.
 
Replies continue below

Recommended for you

jdmcclung,

If I am understanding you correctly, you maybe be experiencing some of the same problems that I have. One of the biggest things that I have found is to make sure that you shut off ALL OSNAPS before your LISP program tries to draw anything. If you need to pick OSNAP points during the LISP program, make sure that you shut off the OSNAPS, turn them on just before asking to select the point, and then shut them off again directly after the LISP program gets the point. I have had some strange results when I forgot to add this in.

Also, I agree with you that sticking to using the WCS and using polar is a better option.

Hope this helps,
Paul
 
I guess basically I want to either get the polar command to go off the UCS instead of the WCS or a use a command other than polar that will go off the ucs.
 
To get it to draw using the UCS you can replicate command line entry, e.g:

(command "line" "@" "@23.5<45" "")

Or, you can calculate each point using the "polar" function, then use the "trans" function to convert from WCS to UCS.

 
The problem with (command "line" "@" "@23.5<45" "") is that the angle and distance will change. The problem with trans and the polar function is that if it reads (setq pt2 (polar pt1 (dtr 180) 5)) it will go 180 degs off the WCS, but I want it to go 180 deg. off the UCS. I've tried trans, but it dod not seem to work correctly.
 
You can use variable input to the command-line format. Using your example
(setq pt2 (polar pt1 (dtr 180) 5))
You could draw a line from pt1 to pt2 with

(command "line" pt1 (strcat "@" (rtos 5) "<" (itoa 180)) "")

You could also get the polar command to work if you added your pre-defined angle to the UCS rotation angle. You can get the UCS angle from the UCSXDIR system variable.
 
I guess I am still missing something. Here is a snipit of the code that I have written. First I get the insertion point(inspt) then off that calculation the 15pts needed. Then I draw the first line. I next rotate the ucs around the Z axis equal to the first angle. Here is where I am running into trouble. PT4 is not apearing where it is supposed to which is causing the next arc to fail. I think it might be where I am rotating the ucs, but I need it rotate before I call to pt4. If any one can see something i am not let me know. Thank you.


(setq inspt (getpoint "\n Pick insertion point."))
(setq pt1 (trans (polar inspt (dtr ia1) oro1) 0 1)
pt2 (trans (polar pt1 (dtr ia1) l2) 0 1)
pt3 (trans (polar pt2 (dtr ia1) oro2)0 1)
pt4 (trans (polar pt3 (dtr ia2) oro2) 0 1)
pt5 (trans (polar pt4 (dtr ia2) l3) 0 1)
pt6 (trans (polar pt5 (dtr (- ia2 90)) at) 0 1)
pt7 (trans (polar pt6 (dtr (- ia2 180)) l3) 0 1)
pt8 (trans (polar pt7 (dtr (- ia2 180)) iro2) 0 1)
pt9 (trans (polar pt8 (dtr (- ia1 180)) iro2) 0 1)
pt10 (trans (polar pt9 (dtr (- ia1 180)) l2) 0 1)
pt11 (trans (polar pt10 (dtr (- ia1 180)) iro1) 0 1)
pt12 (trans (polar pt11 (dtr 0) iro1) 0 1)
pt13 (trans (polar pt12 (dtr 0) l1) 0 1)
pt14 (trans (polar pt13 (dtr 270) at) 0 1)
pt15 (trans (polar pt14 (dtr 180) l1) 0 1)
)
(command "line" pt1 pt2 "")
(command "ucs" "z" ab)
(command "arc" pt4 "e" pt2 "r" orad)
(command "line" pt4 pt5 pt6 pt7 "")
(command "arc" pt7 "e" pt9 "r" ir)
(command "ucs" "z" a11)
(command "line" pt9 pt10 "")
(command "arc" pt10 "e" pt12 "r" ir)
(command "line" pt12 pt13 pt14 pt15 "")
(command "arc" pt1 "e" pt15 "r" orad)
(command "rotate" "l" "" inspt PAUSE)
 
your line of defining pt3
seems to be missing a space
after the next to last bracket.

pt3 (trans (polar pt2 (dtr ia1) oro2) 0 1)

I hope that is it.
 
Nope, that's not it, spaces aren't necessary. Here's my guess: You calculated your points, and performed a "trans" from world to the current UCS. When you change the UCS, your calculated points are no longer valid for the new UCS. Maybe you should first perform your UCS change, then calculate needed points. And then you wouldn't need a "trans" once you have your starting angle in the current UCS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor