×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Polar Autolisp Command

Polar Autolisp Command

Polar Autolisp Command

(OP)
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.

RE: Polar Autolisp Command

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

RE: Polar Autolisp Command

(OP)
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.

RE: Polar Autolisp Command

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.

RE: Polar Autolisp Command

(OP)
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.

RE: Polar Autolisp Command

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.

RE: Polar Autolisp Command

(OP)
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)

RE: Polar Autolisp Command

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.

RE: Polar Autolisp Command

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources