Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert block with "Pick Point on Line" Prompt

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
ASCunningham
876 Views, 11 Replies

Insert block with "Pick Point on Line" Prompt

I have a lisp routine that I would like to add to. Right now when running the macro the user is not prompted to "Pick Point On Line" in this example

 

(command "insert" blk "s" var1 pause pause))

 

I have added the line

(setq pt1 (entsel "Pick Point On Line "))
(command "insert" blk pt1 "s" var1 pause pause))

but the command doesn't seem to like my PT1 value

 

BLK and VAR1 are set in another lisp routine.

11 REPLIES 11
Message 2 of 12
alanjt_
in reply to: ASCunningham

Use GETPOINT instead of ENTSEL.

Message 3 of 12
ASCunningham
in reply to: alanjt_

Command: asctest Pick Point On Line
X2D corner point, or option keyword.
error: Function cancelled

 

Still no luck

Message 4 of 12
alanjt_
in reply to: ASCunningham

Tested and works (slight mod because I don't have your block or know the var1 variable.

 

(if (setq pt1 (getpoint "\nPick Point On Line "))
  (command "_.-insert" "E-FLOW" "_non" pt1 "_S" 1. pause pause)
)

 

Message 5 of 12
ASCunningham
in reply to: alanjt_

Command: (if (setq pt1 (getpoint "\nPick Point On Line ")) (command "_.-insert" "h21" "_non" pt1 "_S" 1. pause pause) )

Pick Point On Line
X2D corner point, or option keyword.
error: Function cancelled

 

I changed your block to something I have in my drawings and the command still cancels out.

Message 6 of 12
alanjt_
in reply to: ASCunningham

I'm concerned about your error message. What's "X2D corner point, or option keyword."

Message 7 of 12
ASCunningham
in reply to: alanjt_

I'm not sure. That's what shows on the command line after I select my point on the line.

Message 8 of 12
ASCunningham
in reply to: ASCunningham

Ok, this works:

 

(setq pt1 (getpoint "\nPick Point On Line "))
(command "insert" blk "s" var1 "_non" pt1 pause)

 

But I would also like to add a prompt for "Direction or Rotation" of valve. Right now the prompt for "Pick point on Line" shows untill the command finishes.

Message 9 of 12
alanjt_
in reply to: ASCunningham

(if (setq pt1 (getpoint "\nSpecify point on line: "))
  (progn (princ "\nSpecify rotation: ")
         (command "_.insert" blk "_s" var1 "_non" pt1 pause)
  )
)

 

Message 10 of 12
ASCunningham
in reply to: alanjt_

That was it thank you!!

Message 11 of 12
alanjt_
in reply to: ASCunningham

You're welcome.

Message 12 of 12
ASCunningham
in reply to: alanjt_

I have a new issue. All of my buttons are setup as individual custom commands so the buttons will repeat themselves with enter,right click,etc.

 

I use this to insert the block:

(defun c:ball_valve ()

(if (setq pt1 (getpoint "\nSpecify point on line: "))
(progn (princ "\nSpecify rotation: ")
(command "insert" blk "s" var1 "_non" pt1 pause)))

 

Then I have found this lisp routine to break the line the block is placed on.  

(defun abbe ( / *error* enx sel )
    (defun *error* ( msg )
        (LM:endundo (LM:acdoc))
        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
            (princ (strcat "\nError: " msg))
        )
        (princ)
    )
   
    (while
        (progn
            (setvar 'errno 0)
            (initget "Rotation")
            (princ (strcat "\nAutomatic Block Rotation: " (getenv "LMac\\ABBRotation")))
            (setq sel (entsel "\nSelect Block to Trim [Rotation]: "))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, Try Again.")
                )
                (   (= "Rotation" sel)
                    (initget "ON OFF")
                    (setenv "LMac\\ABBRotation"
                        (cond
                            (   (getkword
                                    (strcat "\nAutomatic Block Rotation [ON/OFF] <"
                                        (getenv "LMac\\ABBRotation") ">: "
                                    )
                                )
                            )
                            (   (getenv "LMac\\ABBRotation")   )
                        )
                    )
                )
                (   (= 'ename (type (car sel)))
                    (cond
                        (   (/= "INSERT" (cdr (assoc 0 (setq enx (entget (car sel))))))
                            (princ "\nObject must be a block.")
                        )
                        (   (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (cdr (assoc 8 enx)))))))
                            (princ "\nSelected block is on a locked layer.")
                        )
                        (   t
                            (LM:startundo (LM:acdoc))
                            (LM:AutoBlockBreak (car sel) (= "ON" (getenv "LMac\\ABBRotation")))
                            (LM:endundo   (LM:acdoc))
                        )
                    )
                    t
                )
            )
        )
    )
    (princ)
)

 

The problem is on the button to run both commands I have:

ball_valve;\\abbe;last;;

 

This will work correctly but it will only repeat the "abbe" command and not insert the block again. Is there a way to combine these two lisp so I have both commands repeat?

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost