svorgodne Posted July 23, 2020 Posted July 23, 2020 Hello everyone, I developed a routine that updates blocks from a specific folder on the server as follows: Command: UBV Update selected blocks or all of them? [Selection/All/Name]: I want to specify a name for many drawings for all to update the same block. I know I can run the command like this: (c:UBV) But I want to add the subroutines "N" (for the name variable) "BlockName" (for the block name) Since this is a command that I developed, I cannot run it like this: (command "UBV" "n" "BlocknName" ) Because it is not an AutoCAD command. My question is: Can I run a self developed command (c:UBV) adding subroutines? My first guess was something like but it didin't work. (C:UBV "n" "BlockName") What would be the syntaxis to add subroutines from a self developed Lisp program? Thanks in advance Quote
Jonathan Handojo Posted July 24, 2020 Posted July 24, 2020 (edited) You basically don't. That's why other programmers such as our legend Lee Mac do something like this: Outline Objects Notice he created another function (LM:outline) that accepts an argument. In your case, you'd want to build a function that accepts 2 arguments, and then call the function. He then created the function (c:outline) and in that, he call the function LM:outline. I do use LM:outline too for other purposes and because LM:outline returns a selection set, I can then use it to do other stuff with it on other functions. The purpose of this is so that you can do something like what you're encountering now and gives more flexibility for users to modify any variables to suit their needs: (defun ubv (arg1 arg2 / ) ;; your codes ;; Better have your function return something so that you can use the return values for something else outside it. ) (defun c:ubv nil (ubv "n" "Block Name")) (defun c:ubv2 nil (ubv "n2" "Block Name 2")) (defun c:ubvp nil (ubv (getstring t "\nSpecify name for drawing: ") (getstring t "\nSpecify block name: "))) ;; and so on Edited July 24, 2020 by Jonathan Handojo Quote
Stefan BMR Posted July 24, 2020 Posted July 24, 2020 (defun c:ubv1 ( / ) (vl-load-com) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object) ) "UBV n BlockName " ) (princ) ) 1 Quote
svorgodne Posted July 27, 2020 Author Posted July 27, 2020 On 7/24/2020 at 10:26 PM, Stefan BMR said: (defun c:ubv1 ( / ) (vl-load-com) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object) ) "UBV n BlockName " ) (princ) ) Wonderful Stefan. Thanks a lot. There is always who has an answer. 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.