I'm trying to pull the attribute value out of a block but I'm hitting a bit of a wall. The block's name is fixed (ShtScale), the attribute tag is also fixed (Scale), but I'm not sure what functions I would use to pull this information out as I don't know how its stored. To make this a bit more tricky, I can't use any of the VL, VLA, or VLAX functions as this is part of a larger routine that I run thru accoreconsole and it won't accept any of those (even after loading the acapp.arx). This also means I can't use any user prompts, but I don't really see as being too big of an issue as the block name and att value are both 100% fixed and always will be for the purpose of this function. So far the only snipped of code I've gotten to is:
(setq blk (ssget "_X" '((0 . "INSERT") (2 . "ShtScale") (410 . ltab))))
But this brings up issue 2 that I've hit a wall with, which is how to pass the layout tab name of the current layout tab to the selection set. I've tried this:
(setq ltab (getvar "ctab"))
But what gets set to the "ltab" variable isn't useable in the selection set filter as I'm currently using it and I don't understand why.
Ideally the information it should pull from the block is: "1/8" = 1'-0""
The reason that your variable
ltabis not being evaluated within thessgetfilter list is due to the use of the apostrophe, which quotes the list as literal data (i.e. not to be evaluated). You can find more information about the use of the apostrophe and quote function by reading my tutorial here.To evaluate the
ltabvariable, you'll need to construct thessgetfilter list using thelistandconsfunctions, e.g.:Here, the literal data remains quoted, but the
ltabvariable will be evaluated when theconsexpression is evaluated to return a dotted pair.I should note that if your target block is dynamic, you'll also need to include anonymous block references in the selection set, otherwise dynamic block references with the target block name whose dynamic parameters have been modified will be ignored.
You'll then need to iterate over the selection set to operate on each block reference entity individually. There are many ways to do this. Personally, I like to opt for a basic
repeatloop, e.g.Attribute references held by a block reference will follow the block reference entity in the drawing database, until a terminating
SEQENDentity is reached. With this information, you can use theentnextfunction to iterate over the drawing database records following the block reference entity, until you reach aSEQENDentity.Here is a basic example of this:
Here, the attribute value for each block reference will be held by the
valvariable.