Jump to content

How can I get this code to determine which point is shorter then use that as the offset for 200mm?


Recommended Posts

Posted (edited)
(defun c:dr209 ( / pt1 pt2)
(while (setq pt1 (getpoint "\nPick 1st point "))
  (setq pt2 (getpoint "\nPick point 2 & Base Point "))
  (command "dim" "ver" pt1 pt2 (mapcar '+ pt2 (list 200.0 0.0 0.0)) "" "exit")
)
(princ)
)

Got this code from Bigal, all working great but currently trying to configure it to have an IF statement to determine which of pt1 and pt2 is shorter, it will be using that pt for the variable "(command "dim" "ver" pt1 pt2 (mapcar '+ pt2 (list 200.0 0.0 0.0)) "" "exit")" which is set to pt2 at the moment.

Tried this, but won't work:
 

(defun c:dr1 ( / pt1 pt2 shorter-pt)
(while (setq pt1 (getpoint "\nPick 1st point "))
(setq pt2 (getpoint "\nPick point 2 & Base Point "))
(setq shorter-pt (if (< (distance pt1 pt2) (distance pt2 (mapcar '+ pt2 (list 200.0 0.0 0.0)))))
pt1
pt2)
(command "dim" "ver" pt1 pt2 (mapcar '+ shorter-pt (list 200.0 0.0 0.0)) "" "exit")
)
(princ)
)

 

Edited by AeJay
  • AeJay changed the title to How can I get this code to determine which point is shorter then use that as the offset for 200mm?
Posted

Admin please join to other post re this task 

 

You should have asked me, this is to do with the bottom right dim in your sample dwg, the answer is yes work out which is shorter then swap pt1 and pt2. 

An example

(setq d1 (distance p1 p3)
	d2 (distance p2 p3)
)
(if (> d1 d2)
    (progn 
    (setq temp p1)
    (setq p1 p2)
    (setq p2 temp)
    )
)

 

  • Thanks 1

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