Jump to content

Recommended Posts

Posted (edited)

Here is what I am trying to do.
Draw a TRIM - FENCE from these two points to cut the vertical lines

 

image.thumb.png.68ec9da2c95036a35c2e6bfb33411ff9.png


Here is my code

 

(setq pt1 "0.5,1.0,0.0")
(setq pt2 "3.0,1.0,0.0")
(command "trim" "fence"  pt1 pt2)


If I execute this code,  I get this
(the lines are not trimmed)

 

image.thumb.png.63ca02eb7f6b71ba5c3cb2a1fb27ba94.png

 

If I manually type TRIM - FENCE - !PT1 - !PT2
I get this
(it works, I have to press enter to finish)

image.thumb.png.fc309ded049c48229d68bb773ba89b13.png

 


What am I missing in getting this code/command to work the way I want?

 

Edited by ILoveMadoka
Posted (edited)
(defun c:FOO (/ pt1 pt2)
  (if
    (and
      (setq pt1 (getpoint "\nSpecify first point: "))
      (setq pt2 (getpoint pt1 "\nSpecify second point: "))
    )
     (command-s "._trim" "_o" "_s" "" "_f" pt1 pt2 "" "")
  )
  (princ)
)

 

Edited by BlackBox
  • Agree 1
Posted (edited)

I know that's how command line works (typing in points), but you have to pass it a list. so either use getpoint or use the following to hard code x y z.

 

(setq pt2 '(0.5 1.0 0.0))
or 
(setq pt2 (list 0.5 1.0 0.0))

 

Asks user to set points with getpoint. used the first point so you can see the fence. defaults do your point if nothing is picked.

 

(setq pt1 (getpoint "\nPick Point<0.5, 1.0, 0.0>: "))
(if (= pt1 "")(setq pt2 '(0.5 1.0 0.0)))
(setq pt2 (getpoint pt1 "\nPick Point<0.5, 1.0, 0.0>: "))
(if (= pt2 "")(setq pt2 '(3.0 1.0 0.0)))  ; '(makes it a list

 

-edit 

using @BlackBox Command-s means it wont run the command unless both points are defined. good for error handling

 

 

 

Edited by mhupp

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