Jump to content

Nested Symbol Name field in a Report


Recommended Posts

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

Link to comment
  • 2 years later...
  • 5 months later...

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);

 

  • Like 1
Link to comment
  • 2 months later...

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');

 

 

Link to comment

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);

 

Link to comment

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);

 

Link to comment

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

Link to comment

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.

 

Link to comment

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?

 

Link to comment

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.

Link to comment

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.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...