CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
Czech English Deutsch
Login/Register:
 Visitors: 3838 
RSS tips RSS channel - CAD tips
RSS discussion RSS channel - CAD discussion

Discussion Discussion forum

HelpCAD discussion

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

LISP define the position of a rectangle

 Post Reply Post Reply
Author
lumpy92 View Drop Down
Newbie
Newbie


Joined: 02.Jun.2017
Location: Hungary
Using: AutoCAD2013
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote lumpy92 Quote  Post ReplyReply Direct Link To This Post Topic: LISP define the position of a rectangle
    Posted: 29.Jun.2017 at 14:19
Hi all!

I try to write an autoLISP execution.
I need to draw rectangles with it. After I define the first point, I send "d" (diameters dimensions), then I send the numbers for it's height and width. But at the end, I need to select it's position with the cursor.
My question is: is there any possible way, to do that WITHOUT the cursor? I want it to draw it into the right bottom position every time (and write it into my LISP code).

Thank you for your suggestions! Wink


Edited by lumpy92 - 29.Jun.2017 at 15:07
Back to Top
John Connor View Drop Down
Senior Member
Senior Member


Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 6580
Post Options Post Options   Thanks (0) Thanks(0)   Quote John Connor Quote  Post ReplyReply Direct Link To This Post Posted: 29.Jun.2017 at 15:01
Wouldn't that "D" be for "Dimensions?  Why would you specify diameters if you are drawing rectangles?  Makes no sense.
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>

Back to Top
lumpy92 View Drop Down
Newbie
Newbie


Joined: 02.Jun.2017
Location: Hungary
Using: AutoCAD2013
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote lumpy92 Quote  Post ReplyReply Direct Link To This Post Posted: 29.Jun.2017 at 15:06
Sorry, my fault. It is stand for Dimensions.
Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD, Architectural Desktop
Status: Offline
Points: 362
Post Options Post Options   Thanks (1) Thanks(1)   Quote Kent Cooper Quote  Post ReplyReply Direct Link To This Post Posted: 29.Jun.2017 at 19:54
Simple example, lightly tested:
(defun C:TEST () (command "_.rectang" pause "_d" 15 10 (polar (getvar 'lastpoint) (* pi 1.75) 10)))
 
The red part will feed in a point always in the right-bottom-ward direction.  Adjust the blue parts to suit your needs, or use pauses for the first two, if you want to give it different sizes each time.
Back to Top
lumpy92 View Drop Down
Newbie
Newbie


Joined: 02.Jun.2017
Location: Hungary
Using: AutoCAD2013
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote lumpy92 Quote  Post ReplyReply Direct Link To This Post Posted: 03.Jul.2017 at 15:49
Thank you very much, it is works Wink
Back to Top
lumpy92 View Drop Down
Newbie
Newbie


Joined: 02.Jun.2017
Location: Hungary
Using: AutoCAD2013
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote lumpy92 Quote  Post ReplyReply Direct Link To This Post Posted: 03.Jul.2017 at 16:05
Could you explain me what is the difference between ._rectangle and _rectangle?
Why is the dot is necessary? Both of them works for me.
Thanks!
Back to Top
John Connor View Drop Down
Senior Member
Senior Member


Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 6580
Post Options Post Options   Thanks (0) Thanks(0)   Quote John Connor Quote  Post ReplyReply Direct Link To This Post Posted: 04.Jul.2017 at 13:27
Adding the "dot" before a command name ensures that the generic AutoCAD command will be used instead of one that might be substituted (or missing) by virtue of the command having been undefined.
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>

Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD, Architectural Desktop
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kent Cooper Quote  Post ReplyReply Direct Link To This Post Posted: 05.Jul.2017 at 18:48
Another way to do it, that uses the RECTANG command without the Dimensions option, but rather by calculating the opposite corner in the right-bottom-ward direction:
 
(defun C:RULS (/ UL xdim ydim); = Rectang from Upper Left by specifying Size
  (setq
    UL (getpoint "\nUpper Left corner: ")
    xdim (getdist "\nHorizontal size: ")
    ydim (getdist "\nVertical size: ")
  )
  (command "_.rectang" UL (mapcar '+ UL (list xdim (- ydim))))
  (princ)
)
 
An advantage is that the prompts are clearer about what is being asked for.  I can never remember which direction they mean for "length" and "width" in RECTANG's Dimension-option prompts, and I can easily get it wrong because I think of "width" as being horizontal, but they use "length" for the horizontal size and "width" for what I would prefer to call "height."
 


Edited by Kent Cooper - 05.Jul.2017 at 18:52
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,070 seconds.