• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

repeat autolisp sequence inserted in menu item

  • Thread starter Thread starter Gio_S
  • Start date Start date

Gio_S

Guest
good evening to all, I wondered if there is a chance to repeat, right-click, not only the last command performed, but also the menu items I created with short sequences in autolisp.
I am born of the problem because I would like to act continuously, with repeat shots, selecting the cadauna units, simply recalling the menu item just executed.
Unfortunately, if I have just run the file code inserted in the custom menu item, and I click the right mouse button, my intellicad certainly goes to repropose the last command executed, but referring to the regular autocad command, last, which I had performed earlier. my command "custom" written in autolisp does not "remember" it anymore.
I don't know if I was clear...
Thank you!
g.
 
I don't know if it works in k... but in autocad in a menu item by applying a * to the menu item code/command you get the repetition until you enter ctrl-c..

an alternative can define a command (c:...) ie:
Code:
[voce di menu]^c(defun c:mio_comando ( ) ... . . . . )(c:mio_comando)
so that by sending it is repeated .
 
Thanks for the tips, but where should I put the asterisk in the menu? This is the voice.[Block positive X scale]^c^c^p(setq spex(entget(car(entsel))))(setq ox (assoc 41 spex))+ (prompt (strcat "writing positive x")(setq nx (* -1(cdr ox)))+ (setq spex(subst(cons 41 nx)(assoc 41 spex)spex))+ (entmod spex)(setq ox (assoc 41 spex))(princ) ^pwith the c command in the lisp I tried, and it works the repetition, but I use to put so many features in a defunct sololisp editing. . so, it works yes, but it gives me the choice between all my commands of the file lisp.
I should break this function by myself, but I am reluctant to break my extensions ..
Anyway in the c I just entered the command with the usual selection, so it acts on the blocks I sent to the loop, and this speeds me anyway... and by the way it avoids the error if it does not find blocks (which happens to me from menu if they select another entity that is not a block).

but I'm curious about the asterisk... I tried various positions, in some gives unrecognized command error, in others does not take into account and the command does nothing .. I did not understand well where to put the asterisk
Thank you!
 
a thousand thanks! tested now, nothing, my intellicad does not give error but ignores it, the repetition uses the previous command, so I took away the doubt and thank you, and in the end I made the edit robust by means of a lisp block inserted in my general usage extension.
my code "short" from menu has many drawbacks, gives error if it is not a block, does not highlight the object, and especially swaps the sign of x, in case it is already positive makes it negative. to benefit perhaps of no one but I put the correct final code.
I'm serving as a flurry because I've found a strange eventuality in so many of my models of my archive for stl. often using the mirror of the whole model, for example for a half car, all mirrored blocks had the sign of x turned into negative.
without consequences for the design cad because they are symmetrical blocks, specular in axis ... but all wrong in the stl because each face of the block exchanged the inside/outside because of the opposite order that assumed the vertices. What a disaster in the slate.
I actually did a routine to fix the faces after a mirror, but obviously left me the "inverse" blocks. once exploded (in archive I certainly don't hold the exploded blocks) to transfer the whole into the stl, each their face was wrong (vert 1,2,3 became 3,2,1)

Code:
(defun positivexgrid()(setq memblock 0)
(prompt "\nrende positive la scala x nei blocchi selezionati <point cro="" las="" pre="" win="">.")
(setq selez(ssget)))
(if(/= selez nil)
(progn)
(modalite)(setq l(sslength selez)(setq l(1-l))(setq a 0)
(while(<= a l)
(progn)
(setq ename(ssname selez a))(setq alist(entget ename)))
(if(= "insert"(cdr(assoc 0 alist))))
(progn)
(setq ename(ssname selez a)))
(setq spex(entget ename)))
(setq ox (assoc 41 spex))
(if (< (cdr ox) 0)
(progn)
(prompt (strcat "\nwriting x sign"))
(setq nx (* -1(cdr ox)))))
(setq spex(subst(cons 41 nx)
(assoc 41 spex)spex)
(entmod spex)
(setq ox (assoc 41 spex))
(setq memblock 1)
)
)
)
)
)
(setq a(1+ a))
)
(if(/= memblock 0)
(prompt "\nx successful.")
(prompt "\nno block selected". ")
)
(ripristin)
)
)
)</point>
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top