Hey guys, Im trying to run a lisp file to make all blocks (dynamic and non-dynamic) explodeable. I have tons of blocks that are set to not allow exploding and its a pain to go into the block editor and do it all by hand. Im working on a lisp file and this is what i have. It gives the error too few arguments. Help plz
@Anonymous wrote:... Im working on a lisp file .... It gives the error too few arguments. Help plz
(defun c:bex (flag / entblk objblk)....
I'm not sure this is the cause of that particular message, exactly, but commands defined with (defun C:... are not allowed to have before-the-slash arguments. Maybe you want it to be a non-command [non-C:] function instead.
I didn't look too long at this but I think that "FLAG" is the problem like Kent pointed out. You can try calling the command this way in the command line:
(C:BEX T)
and see if that solves the problem. Or you may want to delete flag altogether so it just reads (/ entblk objblk)
and then comment out this line (if flag :vlax-true :vlax-false). I haven't tested to see what effects this will have but it's worth a try.
okay.. I think when you call bex you are supposed to do it this way..
(C:Bex T) - to make blocks explodable
(C:Bex nil) - to make them non-explodable.
@Shneuph wrote:I didn't look too long at this but I think that "FLAG" is the problem like Kent pointed out. ....
...I think when you call bex you are supposed to do it this way..
(C:Bex T) - to make blocks explodable
(C:Bex nil) - to make them non-explodable.
That's very interesting. This section:
AutoLISP Developer's Guide / Using the AutoLISP Language / AutoLISP Basics / Symbol and Function Handling / C:XXX Functions
explicitly says that commands defined with the C: prefix "must be defined with no arguments." But I tried a simple test:
(defun C:TEST (where)
(command "_.line" where (getvar 'viewctr) "")
)
and ran it like this:
(C:TEST '(0 0 0))
and sure enough, it drew a Line from 0,0,0 to the middle of the screen! So I guess the Developer's Guide is incorrect about that, and using it as Shneuph suggests ought to work.
Kent - I still don't fully understand the differences between C: functions and ones w/o the "C:" and how they are used differently. I do know that some built-in autolisp functions have "optional" arguements which you cannot have with a C: function. To get around this I have something like C:Symbol (P1 P2 P3 Poptional1 Poptional2 / etc etc)
Then in the lisp I just test to see if Poptional1 or Poptional2 are nil and if so adjust appropritely. Then call the function like
(C:Symbol "p1" "p2" "p3" "po1" nil)
In the lisp it will have:
(if Poptional1
(do this)
);if
(if Poptional2
(do this)
);if
ok guys,
I have my lisp file and now i want to run it on multiple drawings using script pro. How do i do this?
Not familiar with Script Pro. Does that even allow user input when you're running a script on muptiple drawings? You're going to still have to select the block entity in each drawing the way your lisp is now. Is it a single block that you want to make explodable in multiple drawings or multiple blocks?
@Shneuph wrote:Kent - I still don't fully understand the differences between C: functions and ones w/o the "C:" and how they are used differently. I do know that some built-in autolisp functions have "optional" arguements which you cannot have with a C: function. To get around this I have something like C:Symbol (P1 P2 P3 Poptional1 Poptional2 / etc etc)
Then in the lisp I just test to see if Poptional1 or Poptional2 are nil and if so adjust appropritely. Then call the function like
(C:Symbol "p1" "p2" "p3" "po1" nil)
In the lisp it will have:
(if Poptional1
(do this)
);if(if Poptional2
(do this)
);if
Things defined with the C:, e.g. (defun C:Whatever... are commands [I assume that's what the C stands for], though they are also sometimes referred to as routines, and their command names can be typed at the Command: prompt line without parentheses, as with other commands, or put in menu items, scripts, etc. But since they're not native AutoCAD commands, they can't be used in a Lisp (command) function if they need to be called from inside other Lisp routines, but need to be in parentheses with the C: included. They're not supposed to have arguments, though that doesn't seem to be absolute [see Message 4]. But they can have localized variables.
Things defined without the C:, e.g. (defun Whatever... are usually called routines, or sub-routines, or maybe some other things. [Sometimes someone will refer to one as a function, but that has the potential to be confused with what are properly called functions: those listed in the AutoLISP Reference, including (defun) itself.] You can't type their bare names at the Command: prompt line, though you can type them there included in parentheses, but usually they are used from within other routines, similarly to the way AutoLISP functions are used. They can have arguments [though they don't always need to], as well as localized variables.
In your example, if you're going to use it by calling it from inside another Lisp function/routine, I would just define it as a routine/sub-routine, not as a command, since the C: isn't doing anything for you:(defun Symbol (P1 P2 P3 Poptional1 Poptional2 / etc etc)
and use it the way functions/routines/sub-routines are used:
(Symbol p1 p2 p3 po1 nil)
[Note no quotation marks around the arguments -- I'm assuming those are variables holding some kind of value, and not actually text strings.]
That makes it more clear. Thanks Kent.
[Note no quotation marks around the arguments -- I'm assuming those are variables holding some kind of value, and not actually text strings.]
When I define the routine you are correct that it would look like (Defun C:Function (p1 p2 p3 popt1 popt2 / v1 v2) w/ no quote marks. In the example though p1 p2 p3 are suppsoed to recieve string values so when I call it with (C:Function "p1" "p2" "p3" nil nil) you do pass strings (w/ quotes) to the routine.
Now that you have explained though, I will be changing a few of my routines to not have the C: in front of them since they are being called from a ribbon command w/ something like ^C^C(C:Function p1 p2 p3 etc). Now I know they can just be ^C^C(Function p1 p2 p3 etc) because they aren't being used from the command line as a Commands. As well as any other commands routines/sub-routines that are called only from other Lisp Commands. SHEISH!
Once again, thanks for the valuable input!