View Full Version : Newbie help please!
scoutmaster
2008-12-14, 08:00 PM
Im trying to write a lisp file that will do the following:
Change the UCS to a certain object
Insert a block
Copy that same block multi times
Change the UCS back to world
Ive managed to get the first two steps to work but it seems to blow out before the copy command.
Here is a copy of what I have so far:
(DEFUN C:II()
(COMMAND "UCS" "OB" PAUSE "")
(COMMAND "INSERT" PAUSE "")
(COMMAND "COPY" "" "LAST" "" "M" "" PAUSE "")
(COMMAND "UCS" "WORLD" "")
(PRINC)
)
aaronic_abacus
2008-12-15, 04:11 AM
;This autolisp program sets the ucs by object, inserts multiple blocks, then sets the ucs to world.
(DEFUN C:II()
(COMMAND "UCS" "OB" PAUSE)
(COMMAND "INSERT" PAUSE "" "" "")
(COMMAND "COPY" "LAST" "" "M" "@")
(SETQ LP 1)
(WHILE LP
(IF (> (GETVAR "CMDACTIVE") 0) (COMMAND PAUSE) (SETQ LP NIL))
);END LP
(COMMAND "UCS" "WORLD")
(PRINC)
)
scoutmaster
2008-12-17, 12:22 AM
Thanks much for the help. Now how much trouble would it be to explain the additional lines. Im still trying to learn this without bothering all of you to awful much. This part in particular Im not familiar with:
(SETQ LP 1)
(WHILE LP
(IF (> (GETVAR "CMDACTIVE") 0) (COMMAND PAUSE) (SETQ LP NIL))
);END LP
It is assigning 1 to the variable LP;
Then it starts a while loop and checks to see if the variable LP has a value;
Then in the if statement, it checks to see if the system variable CMDACTIVE is greater than 0. If it is, then it issues a pause for user input. If it is not, then it returns the variable LP to nil.
It then exits the while loop.
It could be simplified to...
(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
scoutmaster
2008-12-17, 02:12 AM
After I tweaked my lines above that, it worked like a top thanks to this Forum.
scoutmaster
2008-12-18, 06:06 PM
It is assigning 1 to the variable LP;
Then it starts a while loop and checks to see if the variable LP has a value;
Then in the if statement, it checks to see if the system variable CMDACTIVE is greater than 0. If it is, then it issues a pause for user input. If it is not, then it returns the variable LP to nil.
It then exits the while loop.
It could be simplified to...
(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
Well I tried going thru the system variables before replying. But to no avail.
You explaination went over my head. Other than in its most basic form you were saying its basically running a short Lisp inside of the main lisp. Or at least thats my understanding.
However I would sure like to understand it a bit better. Sorry for exhibitting such newb traits but hey it is what it is. Thats why Im here.
Well I tried going thru the system variables before replying. But to no avail.
You explaination went over my head. Other than in its most basic form you were saying its basically running a short Lisp inside of the main lisp. Or at least thats my understanding.
However I would sure like to understand it a bit better. Sorry for exhibitting such newb traits but hey it is what it is. Thats why Im here.
I'll try to help explain, but I'm somewhat of a intermediate lisper myself :p
(DEFUN C:II()
(setq cmd (getvar "cmdecho")) ; added this, records current cmdecho setting
(setvar "cmdecho" 1) ; added to make sure you see the command prompts
(COMMAND "UCS" "OB" PAUSE)
(COMMAND "INSERT" PAUSE "" "" "")
(COMMAND "COPY" "LAST" "" "M" "@")
(SETQ LP 1)
(while (> (getvar "CMDACTIVE") 0) ; looks to see if there is a command active or not
(command pause) ;if it is (1 is greater than 0) then it tells autocad to pause
);END LP
(COMMAND "UCS" "WORLD")
(setvar "cmdecho" cmd) ; resets cmdecho to original state
(PRINC)
)
Some one feel free to correct me if I'm wrong.....
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.