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

help with simple lisp program

3 REPLIES 3
Reply
Message 1 of 4
timsea
216 Views, 3 Replies

help with simple lisp program

I'm trying to write a lisp program for MEP to offset a label on a duct, allowing the label then to be moved around with the grips. It should be pretty simple, just a handful of commands to be entered at the command line. What the lisp should do is automate the following process:
1- type LabelCurveOffsetNode at the command line
2- the LabelCurveOffsetNode will ask the user to select a label to be offset
3- type 'y' at the command line in response to whether to offset one at a time
4- type '0.1' at the command line to give it an insignificantly small offset, after which it can be moved with the grip

Step 2 is what I don't know how to do. What I have now is this:

(defun C:labeloffset()
(command "LabelCurveOffsetNode")
(command "Y")
(command "0.1")
(command "")
(princ "\nYOU MAY NOW MOVE THE LABEL WHEREVER YOU WANT")
(princ)
)

But this does not stop for the LabelCurveOffsetNode to prompt to select a label. I need a way to pause my lisp, allow the user to enter information in accordance with the LabelCurveOffsetNode command, then start back up again for the remaining steps. I'd think this should be pretty simple, but I don't really know what I'm doing. Any help is appreciated! Thanks!
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: timsea

I don't have that command available to test, but if it works like most others, you should be able to
put pauses in for User input, with the word 'pause.' You should also be able to put it all into one
(command) function. You'll have to confirm the sequence of prompts, but maybe something like this:

{code}
(command
"LabelCurveOffsetNode"
pause ; for User selection, presumably with the command's own prompt
"Y"
"0.1"
pause ; for User selection of offset side, if that's the way it works
"" ; finish the command
); end Lisp command function
{code}

--
Kent Cooper


timsea wrote...
I'm trying to write a lisp program for MEP to offset a label on a duct, allowing the label then to
be moved around with the grips. It should be pretty simple, just a handful of commands to be entered
at the command line. What the lisp should do is automate the following process: 1- type
LabelCurveOffsetNode at the command line 2- the LabelCurveOffsetNode will ask the user to select a
label to be offset 3- type 'y' at the command line in response to whether to offset one at a time 4-
type '0.1' at the command line to give it an insignificantly small offset, after which it can be
moved with the grip Step 2 is what I don't know how to do. What I have now is this: (defun
C:labeloffset() (command "LabelCurveOffsetNode") (command "Y") (command "0.1") (command "") (princ
"\nYOU MAY NOW MOVE THE LABEL WHEREVER YOU WANT") (princ) ) But this does not stop for the
LabelCurveOffsetNode to prompt to select a label. I need a way to pause my lisp, allow the user to
enter information in accordance with the LabelCurveOffsetNode command, then start back up again for
the remaining steps. I'd think this should be pretty simple, but I don't really know what I'm doing.
Any help is appreciated! Thanks!
Message 3 of 4
timsea
in reply to: timsea

Thanks Kent! Works like a charm! Here's what I ended up doing:

(defun C:labeloffset()

(command
"LabelCurveOffsetNode"
pause "" "Y" "0.01" "")
(princ "\nYou May Now Move the Label")
(princ)

)

This will save me a lot of clicking and menu-looking-through in the future. Edited by: timsea on Dec 29, 2008 12:06 PM
Message 4 of 4
Anonymous
in reply to: timsea

Good. I didn't think of the possibility that you'd need to finish the selection, though maybe I
should have, given what the Yes answer is about.

If you want to get snazzier about it, experiment with (ssget) and its Single option, in place of the
pause. Using that, you should be able to avoid the routine's crashing if the User misses in
selecting a label. And even more, it's also possible to have the routine check whether what they
picked is the right kind of thing, or whether it's on a locked Layer, tell them about any such
problems, and/or ask them to pick again.

--
Kent Cooper


timsea wrote...
Thanks Kent! Works like a charm! Here's what I ended up doing: (defun C:labeloffset() (command
"LabelCurveOffsetNode" pause "" "Y" "0.01" "") (princ "\nYou Can Now Move the Label") ) This will
save me a lot of clicking and menu-looking-through in the future.

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

Post to forums  

Autodesk Design & Make Report

”Boost