MattG Posted August 20, 2020 Share Posted August 20, 2020 I have a drawing I am working on with a bunch of symbols made up of other symbols. I am making a report to show me all the info on the symbols. Is there any function or way of showing a field that shows what symbol a symbol is in? For example I have 5 of symbol A and 8 of symbol B put together to make a thing. I make that thing a symbol and call it symbol Z. I have a report that now shows all the symbols and their record format which is what I am really trying to get out of this. However they are just all in one big list. Is it possible to put in a field/column that shows the parent symbol and then summarize by that field/column? Not sure that totally makes sense. Matt Quote Link to comment
Pat Stanford Posted August 21, 2020 Share Posted August 21, 2020 By default, no, what you are asking for does not exist. I think a worksheet script could relatively easily be created that would show the name of the parent object. Would you want that to show layer names or just blank for items that are on a layer? Quote Link to comment
Popular Post Pat Stanford Posted August 22, 2020 Popular Post Share Posted August 22, 2020 Try this worksheet script. It returns the name of the parent object for each object specified in the database criteria of a database in a worksheet. If the object is on a layer rather than in a container object, the cell says "Object on Layer". Create a new Vectrorscript by copying and pasting everything in the code block below into a new blank script. Run the script in a worksheet by using a column header formula of =RunScript('Name you give the script goes here'). I called this script Get Parent Name to WS. Click the Always button when asked about running the script. The values returned will update when you recalculate the worksheet, not when you make changes in the drawing. Ask again if you need more help. Procedure ParentNameToWS; {August 22, 2020} {©2020 Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {No Warranty Expressed of Implied. Use at your own risk.} {Returns the name of the parent object (not a layer) to a worksheet cell.} {Run usinging a cell formula of =RunScript('ParentNameToWS') if} {the script is stored in the local file.} Var H1:Handle; Begin H1:=GetParent(WSScript_Getobject); If GetTypeN(H1)<>31 then Begin WSScript_SetResStr(GetName(H1)); End Else Begin WSScript_SetResStr('Symbol on layer'); End; End; Run(ParentNameToWS); 6 Quote Link to comment
J Patrick Adair Posted June 20, 2023 Share Posted June 20, 2023 Pat, just hopping in to say thanks for the script! It was exactly what I needed. - Patrick Quote Link to comment
Steve Murray Posted November 22, 2023 Share Posted November 22, 2023 I used the above script successfully in a worksheet listing polylines inside symbols. For some reason it does not works when I list doors inside a symbol. Any Idea? Thanks You Quote Link to comment
Pat Stanford Posted November 22, 2023 Share Posted November 22, 2023 It works for me with doors. What criteria are you using for the database? Are you certain that it is returning Door objects? Quote Link to comment
Steve Murray Posted November 23, 2023 Share Posted November 23, 2023 Thanks Pat, Yes, the door list correctly, I have tested in a fresh file using both styled and unstyled doors. Attached The doors list correctly but the script column has no values for the doors. Thanks Test symbol name doors.vwx Quote Link to comment
Pat Stanford Posted November 24, 2023 Share Posted November 24, 2023 OK, you didn't say that you had a Door in Wall in your Symbol. 😉. So you can't get just the parent (which is the wall) you need the parent of the parent. I have adjusted the code to deal with objects in a Wall inside the Symbol or just objects directly inside the symbol. Replace the existing code with the following and it should work in both cases. Procedure ParentNameToWS; {August 22, 2020} {©2023,2020 Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {November 23, 2023} {Updated to handle objects in Walls inside Symbols} {No Warranty Expressed of Implied. Use at your own risk.} {Returns the name of the parent object (not a layer) to a worksheet cell.} {Run usinging a cell formula of =RunScript('ParentNameToWS') if} {the script is stored in the local file.} Var H1:Handle; Begin H1:=GetParent(WSScript_Getobject); If GetTypeN(H1)<>31 then Begin If GetType(H1)=68 then H1:=GetParent(H1); WSScript_SetResStr(GetName(H1)); End Else Begin WSScript_SetResStr('Symbol on layer'); End; End; Run(ParentNameToWS); 1 Quote Link to comment
Steve Murray Posted November 24, 2023 Share Posted November 24, 2023 Whops...the door in the wall 🤔 Great that worked!!! Thank you very much Pat Quote Link to comment
Steve Murray Posted February 1, 2024 Share Posted February 1, 2024 What if I want to get the field of a record attached to the parent symbol? ExampleField of ExampleRecord. Could anyone please help with that? I tried asking chat GPT but it did not help :) Quote Link to comment
Pat Stanford Posted February 1, 2024 Share Posted February 1, 2024 Are we working with just the Parent of the object, or do we need to consider objects in Walls where the Parent is actually a symbol containing the Wall? Once you have a handle to the object you want, it is very easy to get the Record.Field. If H1 is the handle to the object your want then something like the following where S1 is defined as a string will get the data: S1:=GetRField(H1, 'ExampleRecord', 'ExampleField'); Quote Link to comment
Steve Murray Posted February 2, 2024 Share Posted February 2, 2024 Thanks Pat I ended up with the following which does the job. I'm working with Spaces Worksheet here. Procedure GetExampleFieldFromSpaceToWS; {February 1, 2024} {Custom script to get a field (ExampleField) value from a record attached to the parent symbol of a Space object.} Var spaceHandle: Handle; recordName: String; fieldValue: String; Begin { Get the handle of the current Space object } spaceHandle := WSScript_GetObject; If GetTypeN(spaceHandle) <> 31 then Begin { Specify the record name and field to retrieve } recordName := 'ExampleRecord'; fieldValue := GetRField(spaceHandle, recordName, 'ExampleField'); { Set the result to the worksheet cell } WSScript_SetResStr(fieldValue); End Else Begin WSScript_SetResStr('Not a Space object'); End; End; Run(GetExampleFieldFromSpaceToWS); Quote Link to comment
Steve Murray Posted February 2, 2024 Share Posted February 2, 2024 Actually it does not work, It only write the field value for the symbol itself but not for anything inside of it Any help with this would be greatly appreciated Thanks Quote Link to comment
Pat Stanford Posted February 4, 2024 Share Posted February 4, 2024 You were getting the record from the Space and not from the Parent of the space. See the changes below. Untested, but it should work. Procedure GetExampleFieldFromSpaceToWS; {February 1, 2024} {Custom script to get a field (ExampleField) value from a record attached to the parent symbol of a Space object.} {February 3, 2024 Updated by Pat Stanford } Var spaceHandle: Handle; recordName: String; fieldValue: String; Begin { Get the handle of the current Space object } spaceHandle := WSScript_GetObject; If GetTypeN(GetParent(spaceHandle)) <> 31 then {Added GetParent} Begin { Specify the record name and field to retrieve } recordName := 'ExampleRecord'; fieldValue := GetRField(GetParent(spaceHandle), recordName, 'ExampleField'); {Added GetParent} { Set the result to the worksheet cell } WSScript_SetResStr(fieldValue); End Else Begin WSScript_SetResStr('Not a Space object'); End; End; Run(GetExampleFieldFromSpaceToWS); Quote Link to comment
Steve Murray Posted February 5, 2024 Share Posted February 5, 2024 Thank you, Pat, for your ongoing assistance. What I'm working on here involves retrieving the Field values associated with the Parent Symbol and then writing them into a worksheet cell to create a comprehensive list of the symbol's contents. These symbols represent layouts for flats, including features like walls, doors, and spaces. My client has requested a schedule that details the elements within each flat, such as spaces, doors, windows, and more, while also specifying the flat to which each element belongs. Given that I have multiple instances of each flat layout, I've opted to use symbols for consistency. I have been trying the whole weekend but my scripting abilities are very basic. I'm not even sure if what I'm trying to get is possible to be honest. I attach a small file I have been using to test this the script. VW Test.vwx Quote Link to comment
Pat Stanford Posted February 5, 2024 Share Posted February 5, 2024 I don't think you can do what you are trying to do. The Space is not part of the Symbol Instance that you have the record attached to, It is part of the Symbol Definition. As far as I know, there is no way to go back from a Symbol Def to the Symbol Instance to get the record attached to the instance. You MIGHT be able to work up something that would work the other way around and make the worksheet of Symbols instead of Spaces and then dig into the Symbol Def to pull out the space information. I will think about this some more, but I don't know that there is a solution for the way you have information setup. Quote Link to comment
Steve Murray Posted February 6, 2024 Share Posted February 6, 2024 Thanks Pat for looking into this again. I'll give a try to the symbol worksheet. I note in my worksheet the spaces get the layer from the symbol instance. Most probably because a Symbol definition does not have a layer? I'll post again if I find a solution. Quote Link to comment
Steve Murray Posted February 6, 2024 Share Posted February 6, 2024 I tried to change approach and simply write a long IFS formula. Because I already have the value attached to the symbol, and I know the combination of Symbol Name + Story will result is a unique value, So I created a schedule listing the symbols with columns calling the symbol name , Story and the Value attached to the symbol . then I exported that as CSV and wrote a python script to use such file to write the long IFS list. I ended up with a #OPCODE? as the list is too long. If I remove a third of the IFS I avoid the #OPCODE?. I'm wondering if a similar approach could be used in a script called in a the worksheet cell, as the Story comes from the symbol instance rather than the symbol definition, in association with the Symbol name, maybe that way a unique cell value could be assigned for the spaces inside the different symbol instances? Quote Link to comment
Pat Stanford Posted February 6, 2024 Share Posted February 6, 2024 I don't think it is going to work. There is not a different Space inside each symbol instance. There is only the Space in the Symbol Definition. You are not going to be able to apply information from the Symbol instance to an object inside the Symbol Definition for just that one instance. Any changes you make to the Space (which is in the Sym Def) will be applied to all of the Symbol Instances. If you need to have different data on different Spaces, then you are not going to be able to have them be part of a Symbol. Sorry. Quote Link to comment
Steve Murray Posted February 7, 2024 Share Posted February 7, 2024 Thanks you so much Pat for your continuous support on this. I'm now wondering if this would have worked if I used viewports rather than symbols. Perhaps it's too late for this project, but maybe next one... Quote Link to comment
Pat Stanford Posted February 7, 2024 Share Posted February 7, 2024 I don't think it will work with Viewports either. In either a Symbol Definition or a Viewport, there is only one "Real" Space object. You can't assign different data to that single object in different "views" If you need Spaces to have different data then you have to have different Space objects. Quote Link to comment
Inderfab Posted June 28, 2024 Share Posted June 28, 2024 Hi Pat I have a similar problem that i couldnt solve yet with your solutions. Different symbols with apartment typologies. Inside the Symbol are multiple areas, one has the Class "xx-Wohnungsläche". This area has a database with multiple fixed values. The Symbol itself has a database with the building complex it is in. Same symbol in different buildings, only the field of the attached database is different. I need to make a worksheet which shows only the areas with the specific class and the buildings complex it is in. Your code above shows the name of the parent Symbol Name (it is Object type 16, Symbol definition), this works. Now i need the attached database of the inserted symbol (object type 15) but i can not grasp it. It will return the database if it is attached to the symbol definition, but only the preconfigured value and not the actual value of the inserted symbol. Do you have an idea what to change in the code? Examplefile in the attachment:Wohnfläche.vwx Here the code: Procedure ParentDB; Var H1:Handle; S1:STRING; Begin H1:=GetParent(WSScript_Getobject); If GetTypeN(H1)<>31 then Begin WSScript_SetResStr(GetRField(H1, 'Bau', 'Gebaeude')); End Else Begin WSScript_SetResStr('Symbol on layer'); End; End; Run(ParentDB); Quote Link to comment
Pat Stanford Posted June 28, 2024 Share Posted June 28, 2024 Post a sample file with an apartment symbol and the record attached and I will see what I can do. I think it is still too early here for me to figure out our question. 😉 Quote Link to comment
Inderfab Posted June 28, 2024 Share Posted June 28, 2024 4 minutes ago, Pat Stanford said: Post a sample file with an apartment symbol and the record attached and I will see what I can do. I think it is still too early here for me to figure out our question. 😉 The example is attached in the post. Thank you very much. It Quote Link to comment
Pat Stanford Posted June 28, 2024 Share Posted June 28, 2024 I don't think you can do what you want to do. Symbol Instances in a drawing are all just links to a single Symbol Definition. Every one is going to be identical. If you change the data on an object inside one symbol instance you are actually changing the data in the definition which is going to change every symbol instance. You could attach the record to the Symbol rather than an object inside the symbol and then you could have different data for different symbol instances. You could even make multiple symbols of the symbol with the record attached (with the correct data) and use the Convert to Group option so when you bring it in from the Resource Manager you get a symbol with the record already attached. But you won't be able to have individual information for objects inside a symbol definition. Quote Link to comment
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.