View Full Version : insert an equivalent of the CTAB variable as a field value
draftsit
2008-12-18, 10:06 PM
Hi all
I have a block with a field that doesn't plot (which is what I want). I want the name of the layout that the block is placed on to be returned as the field value. The CTAB variable doesn't work. "Why not?", you ask. Well, we have multiple layout tabs. What I want to do is use the DATAEXTRACTION to count all of the blocks and tell me what layout they are on. This will be extracted to Excel. I want to do this from any given layout, but extract the data from ALL of the layouts. CTAB doesn't work because it inputs the name of the layout that is current when the DATAEXTRACTION is executed. I can use the DATAEXTRACTION on each layout and extract to separate files, but this is very time consuming. I am very new to LISP, but did manage to piece together the lisp below. However, now I am finding that the LISP result cannot be inserted as the field value?? Maybe I am going about this all wrong? Maybe something other than AutoLisp?
Any and all help is appreciated. Here's the LISP I cam up with.
(cdr(assoc 410(entget(ssname(ssget "L")0))))
indianateresa
2008-12-19, 12:14 AM
Drafsit,
I've been banging my head against a wall for three weeks trying to get CTAB to cooperate with EATTEXT - without luck. I've finally settled for using GATTE to update the LAYOUT_TAB attribute in all blocks on the layout sheet.
It's not as neat and tidy as using the CTAB field should be, but since CTAB doesn't seem to work the EATTEXT, it's as close as I could come.
If you have any luck with this, I'd really appreciate hearing how you solved it.
Teresa
Norton_cad
2008-12-19, 02:29 AM
Thinking in non-Lisp for the solution...
I created an attribiute which finds the current CTAB and adds it as a feild, Then I saved the block, and added it to each layout (this could be added to a title block). Then I ran the Attibute extraction wizard, and saved the table to drawing (you could extract it to excel instead). I probably need to tinker with the extraction to make dynamic (if the layout tab is renamed), but as a one off, it seams to work. See the attached AC drawing.
Your comments?
draftsit
2008-12-19, 02:07 PM
Thanks for the quick replies guys. Northon, I'm not sure if you're idea is going to give me what I am looking for. Maybe I'm just not understanding what you are telling me. I am adding a drawing this time showing what is happening. I have inserted the block that I want to count on multiple layouts. I ran the DATAEXTRACTION while RC1 was the current layout. You can see on the table and the Excel result that I clipped that the information returned only lists the pieces as being on the layout that is current when the extraction is ran. However, when you look at each layout individually, the information in correct. (the bottom left corner of each block displays the CTAB value using a field) I want the table and Excel result to list the layout that the block is actually on.
Again, all help is much appreciated.
Baghera
2008-12-19, 05:51 PM
Hi all
I have a block with a field that doesn't plot (which is what I want). I want the name of the layout that the block is placed on to be returned as the field value. The CTAB variable doesn't work. "Why not?", you ask. Well, we have multiple layout tabs. What I want to do is use the DATAEXTRACTION to count all of the blocks and tell me what layout they are on. This will be extracted to Excel. I want to do this from any given layout, but extract the data from ALL of the layouts. CTAB doesn't work because it inputs the name of the layout that is current when the DATAEXTRACTION is executed. I can use the DATAEXTRACTION on each layout and extract to separate files, but this is very time consuming. I am very new to LISP, but did manage to piece together the lisp below. However, now I am finding that the LISP result cannot be inserted as the field value?? Maybe I am going about this all wrong? Maybe something other than AutoLisp?
Any and all help is appreciated. Here's the LISP I cam up with.
(cdr(assoc 410(entget(ssname(ssget "L")0))))
I've never used DATAEXTRACTION and I'm far from an expert in LISP but is there any way you can loop the LISP, store the value for each ctab and then run DATAEXTRACTION?
Norton_cad
2008-12-21, 11:49 PM
Thanks for the quick replies guys. Northon, I'm not sure if you're idea is going to give me what I am looking for. Maybe I'm just not understanding what you are telling me. I am adding a drawing this time showing what is happening. I have inserted the block that I want to count on multiple layouts. I ran the DATAEXTRACTION while RC1 was the current layout. You can see on the table and the Excel result that I clipped that the information returned only lists the pieces as being on the layout that is current when the extraction is ran. However, when you look at each layout individually, the information in correct. (the bottom left corner of each block displays the CTAB value using a field) I want the table and Excel result to list the layout that the block is actually on.
Again, all help is much appreciated.
Thanks for the feeback & upload of the pertanant CAD file. Attached is a screenshot of each stage of the attribute extraction, and the resulting excel file, all as you desire.
Merry Christmas.
draftsit
2008-12-23, 02:49 PM
Norton_cad...thanks for the input. That is the exact process we go through now. Unfortunately we get a different result. When ran here, the extraction shows that all occurences of the block are on the same layout (the layout that is current when the extraction is ran) Maybe there is some sort of setting I am overlooking or that got changed somewhere along the way?????
Norton_cad
2008-12-23, 11:34 PM
Norton_cad...thanks for the input. That is the exact process we go through now. Unfortunately we get a different result. When ran here, the extraction shows that all occurences of the block are on the same layout (the layout that is current when the extraction is ran) Maybe there is some sort of setting I am overlooking or that got changed somewhere along the way?????
Okay. Upload the attached SWF file, launch ACAD & in the express tools, select Tools, System Variable Editor. Then in the dialogue box select, Read, ans navigate to the attached SWF file, and hit okay. Now you have the same system variables active as I do.
Now follow the steps in my previous post, paying close attention to which radio buttons I have switched on or off. Hopfully it should be okay. Please respond if it is or isn't.
Only one more sleep until Santa comes....
steveread
2009-01-22, 09:07 PM
Hi There
I am having exactly the same problem with the ctab not transferring with a data extraction.
It works if you regen all layouts but when you save, etc it all refers back to the current layout.
Would really like to know an alternative if anyone can give some suggestions
That is what the ctab is meant for, the Current Tab.
T.Willey
2009-01-22, 09:22 PM
Hi There
I am having exactly the same problem with the ctab not transferring with a data extraction.
It works if you regen all layouts but when you save, etc it all refers back to the current layout.
Would really like to know an alternative if anyone can give some suggestions
You can use the code here to do what you want. I don't have time to explain, but you can add a field to an object with it. The last one is the latest, but you can read the other posts, only a few, to get a better understand of the code.
[ http://www.theswamp.org/index.php?topic=20446.0 ]
steveread
2009-01-22, 09:48 PM
ok, appreciate your reply.
Looking at it from another angle, is there a system variable that can reference in which layout the block (in my case title block) resides.
If there is i can possibly attach this to the block as a field in addition to the ctab.
Hope you can help.
Regards
Steve
T.Willey
2009-01-22, 10:53 PM
ok, appreciate your reply.
Looking at it from another angle, is there a system variable that can reference in which layout the block (in my case title block) resides.
If there is i can possibly attach this to the block as a field in addition to the ctab.
Hope you can help.
Regards
Steve
No. Stupid forum makes me write a longer reply than is necessary.
irneb
2009-01-27, 07:01 AM
T.Willey, you don't need go through that entire creation to simply make a new Field. If you want to edit an existing field you may need to drill down into those sub-entities as you do. For simple field creation, all that needs to be done is create a string containing the field code, then set this to a text object (TEXT, MTEXT, or ATTRIB), using either vla or entmod - field is created automatically.
As to getting the tab name of an object, you're out of luck using fields. The DXF code of the normal Lisp entity routines does give a 410 code which is the "Containing Layout Name". But the vla ActiveX object (which applies to fields) does not have such a Property. If it had (say) a Property of ContainingLayoutName you could do the following:
Create a field providing the ObjectName of the entity.
Copy the field code as displayed in the bottom of the Field Dialog (e.g. %<\AcObjProp Object(%<\_ObjId 2130424528>%).ObjectName>%)
Paste it into Notepad, and edit the ObjectName to ContainingLayoutName.
Select all and copy (eg. %<\AcObjProp Object(%<\_ObjId 2130424528>%).ContainingLayoutName>%)
Return to AC, and paste into the Text / Attrib value.
Don't edit the field def again (otherwise you'll have to redo the steps above).Unfortunately this won't work as there's no such Property as ContainingLayoutName in the ActiveX objects. It does work for any other property though, even those not shown in the Field dialog.
T.Willey
2009-01-27, 04:55 PM
You can assign the layout name to the field. It won't change if the field is copied to another layout, but if that layout changes, then the field will update. But you can have a routine that will set the field to the current layout, so that wouldn't really be a big problem.
As far as what it takes to create a field; thanks for pointing that out, as I don't use fields. I will see if that works when I get a minute.
irneb
2009-01-28, 06:43 AM
You can assign the layout name to the field. It won't change if the field is copied to another layout, but if that layout changes, then the field will update. But you can have a routine that will set the field to the current layout, so that wouldn't really be a big problem.You mean by getting hold of the ObjectID of the VLA Layout Object? Yes, with some custom code this could be done. Then at least if the layout is renamed it will reflect in the field. But you'd need some sort of reactor to check if the field is copied / moved to another layout - because the field then effectively needs to point to another object.
draftsit
2009-02-27, 10:30 PM
Okay...to anyone interested, here's the solution. I contacted Autodesk support since there was an instance of another user (Norton) being able to achieve a different result using, seemingly the same process. Support told me they were unsure why it ws working that way at all.
They did tell me however, that if you run the extraction on the first and last layout (saving to the same excel file) that the information somehow becomes correct. Running the extraction on the first and last layout didn't work for me, but if I run the extraction on ALL of the layouts (again, saving to the same excel file) I do get the correct result.
Workarounds RULE!!!.....well, not really, but it does work...for now.
Norton_cad
2009-03-01, 04:00 AM
I'm glad the solution I gave solves your problem. Maybe this thread should be moved/copied to "Tips n tricks", or split into two alternative threads.
One based on the Non-lisp programming solution, and the other based on the Lisp/programming solution (which I think is un-resolved).
I'll leave it to the moderator to decide.
Either way I'm stoked your problems are history (for now...).
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.