broncos15 Posted April 28, 2016 Posted April 28, 2016 (edited) I have a quick question on how to get the block object id based on what a user inputs. For example, if the user Input "MH" into a getkword function, how would I search and find that block and get the object id? What I have so far is: (setq blknames (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))) (setq blkname1 (vla-item blknames blkname)) (setq attid (vla-get-objecteid blkname1)) Where blkname is what is returned from the getkword function. This doesn't seem to work though. Edited April 28, 2016 by broncos15 Quote
Lee Mac Posted April 28, 2016 Posted April 28, 2016 Are you looking for the ObjectID of the block definition or a specific block reference? Quote
broncos15 Posted April 28, 2016 Author Posted April 28, 2016 Are you looking for the ObjectID of the block definition or a specific block reference?I am trying to get the object ID so that I can use it with the setblocktablerecordID function. For example, if the user inputs MH (I am using initget so I know that the blocks exist and if they don't exist, then I insert it into the drawing), then I am trying to set the blkID based on their answer. Quote
Lee Mac Posted April 28, 2016 Posted April 28, 2016 I am trying to get the object ID so that I can use it with the setblocktablerecordID function. For example, if the user inputs MH (I am using initget so I know that the blocks exist and if they don't exist, then I insert it into the drawing), then I am trying to set the blkID based on their answer. OK, for that method you will require the ObjectID of the Block Definition - see the count:setblocktablerecord function as part of my Block Counter program for an example. Quote
broncos15 Posted April 28, 2016 Author Posted April 28, 2016 OK, for that method you will require the ObjectID of the Block Definition - see the count:setblocktablerecord function as part of my Block Counter program for an example.Thanks Lee! I'll look at the function and see what I can do. Quote
broncos15 Posted April 28, 2016 Author Posted April 28, 2016 Thanks Lee! I'll look at the function and see what I can do. Lee, that LISP routine was a wealth of knowledge, thank you so much for making it public! I had one more quick question in regards to your steal function. I am trying to have it steal based on a variable name with the following code (if (not (tblsearch "BLOCK" blkname)) (Steal ""C:\\My Folder\\Template.dwt" '( ( "Blocks" (blkname) ) ) ) ) Quote
Lee Mac Posted April 28, 2016 Posted April 28, 2016 You're welcome. You will need to construct the list argument for my Steal function using the AutoLISP list function, as the apostrophe/quote will otherwise render the list as a literal expression, causing the variable to instead be passed as a symbol rather than being evaluated to yield any value it may hold, e.g.: (Steal "C:\\My Folder\\Template.dwt" (list (list "Blocks" (list blkname)))) Lee Quote
broncos15 Posted April 28, 2016 Author Posted April 28, 2016 You're welcome. You will need to construct the list argument for my Steal function using the AutoLISP list function, as the apostrophe/quote will otherwise render the list as a literal expression, causing the variable to instead be passed as a symbol rather than being evaluated to yield any value it may hold, e.g.: (Steal "C:\\My Folder\\Template.dwt" (list (list "Blocks" (list blkname)))) Lee Ahh that makes sense, thanks for the help (and for the awesome Steal routine, it is so useful when writing LISP routines)! I need to do some studying on the list function because I often mess up when I use it (especially when I need 2 list functions). Quote
Lee Mac Posted April 29, 2016 Posted April 29, 2016 I'm glad you find the Steal function useful! - Good luck with your coding. 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.