Drolma Posted March 13 Posted March 13 I am trying to write an autolisp routine to rotate a block about 0,0 in increments of 1 deg. up to 45 degs. to pause and then return back to 0 degs. Thereby simulating the opening and closing of a hatch. The routine below rotates the block just the first 1 deg? (defun c:TEST () (setq x 1) (if (/= (setq nam (getstring T "\nEnter Name of Block: ")) "") (if (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 nam)))) (progn (while (sssetfirst nil ss) (< x 45) (command "rotate" "0,0" 1 "") (setq x (+ x 1)) ); closes while );closes progn );close if );closes if (princ) ) Quote
marko_ribar Posted March 13 Posted March 13 I'd leave the code unchanged - only small intervention if I copy your request well... (while (and (sssetfirst nil ss) (< x 45) ) (command "rotate" "0,0" 1 "") (setq x (+ x 1)) ); closes while Quote
rlx Posted March 13 Posted March 13 (edited) just for fun... block is called 'wieken' (defun c:t2 ( / ce os x bn ss l blist) (vl-load-com) (setq ce (getvar "cmdecho"))(setvar "cmdecho" 0) (setq os (getvar "osmode"))(setvar "osmode" 0) (if (and (setq x 1) (not (eq (setq bn (getstring T "\nEnter Name of Block: ")) "")) (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 bn)))) (setq l (SS->EL ss)) (vl-consp (setq blist (mapcar '(lambda (x) (cons x (getip x))) l))) ) (while (< x 46) (foreach b blist (command "rotate" (car b) "" (cdr b) 1)) (setq x (1+ x)) (redraw) ) ) (setvar "cmdecho" ce) (setvar "osmode" os) (princ) ) ;;; selectionset to entity list (defun SS->EL (ss / i l)(setq i 0)(repeat (sslength ss)(setq l (cons (ssname ss i) l) i (1+ i))) l) ;;; get insertion point (defun getip ( e / p ) (if (and e (setq e (entget e) p (assoc 11 e)) (not (equal p '(11 0.0 0.0 0.0)))) (list (cadr (assoc 11 e))(caddr (assoc 11 e)) 0.0) (list (cadr (assoc 10 e))(caddr (assoc 10 e)) 0.0))) Molens.dwg Edited March 14 by rlx 1 Quote
Drolma Posted March 14 Author Posted March 14 Thanks rlx, I am not familiar with visual lisp but when I ran your solution I received this error message ;- T2 - T2 error: VL_CMDF: not implemented: #<Entity name: 0753AAE0> Any idea what this means? Drolma Quote
Drolma Posted March 14 Author Posted March 14 Thanks Marko-ribar, I tried your suggestion and this is how it ran :- TEST - TEST Enter Name of Block: closedoor Command: rotate RO,ROTATE - Rotate 1 found Current positive angle in UCS: ANGDIR=counterclockwise ANGBASE=0.000000 Specify base point: 0,0 Specify rotation angle or [Copy/Reference angle/]: 1 Select objects or [?] the command line hung up here, which is where I end up no matter what I try to fix it any help would be appreciated. Quote
rlx Posted March 14 Posted March 14 I've updated the code a little by adding (load-vl-com) , I think pretty much most of us loads this command at startup. Also replaced vl-cmdf with standard command function. Don't think it changes very much but you never know. Maybe you have to add a wait function between redraws or replace redraw with regenall if 'animation' goes to fast. It's very difficult if not impossible to get the timing right for every computer because lisp is kinda limmited in some area's. Quote
Drolma Posted March 14 Author Posted March 14 Thanks rlx that was brilliant it works like a charm. I don't know visual lisp but I am going to try and figure it out, that was visual lisp right? Quote
BIGAL Posted March 14 Posted March 14 If the rotation is to fast use (command "delay" 500) I think the number is mirco seconds. Add in RLX code into the while. Quote
Recommended Posts
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.