Jump to content
Developer Wiki and Function Reference Links ×

Assign a record field of a Space PIO to its parent/container symbol


Recommended Posts

Hello,

I'm trying to create a schedule of flats that shows the area of the Space inside each flat symbol instance listed on the schedule. I imagined various way to do so but the most effective for this purpose would be to have a script that get the area of the space inside the symbol and assign it to a custom record field attached to the symbol.

I have been able to put together some basic script in the past but this one exceed my skills by far.

Basically I need a script that retrieve a record field form an object contained in a symbol and assign it to a custom record field of the containing symbol, that should be done for every symbol in the drawing(with some sort of selection criteria es symbol definitions in a specific folder)

Any help would be greatly appreciated!

Link to comment
Hello,

I'm trying to create a schedule of flats that shows the area of the Space inside each flat symbol instance listed on the schedule. I imagined various way to do so but the most effective for this purpose would be to have a script that get the area of the space inside the symbol and assign it to a custom record field attached to the symbol.

I don't really see why you would want to do that. Once you placed all your symbols ( probably because you have a lot of duplicate rooms ) you can get a schedule of all these rooms by listing the space objects. As you are only interested in the area the position in which flat doesn't matter and you'll have a small list instead of a giant list showing duplicates ?

I have been able to put together some basic script in the past but this one exceed my skills by far.

Basically I need a script that retrieve a record field form an object contained in a symbol and assign it to a custom record field of the containing symbol, that should be done for every symbol in the drawing(with some sort of selection criteria es symbol definitions in a specific folder)

Any help would be greatly appreciated!

Make the script look for selected objects. You can get those handles with foreachobject. Check if the selected object matches your symbol name.

When you have the symbol handle get the symbol definition handle so you can traverse the contents. Once the object inside matches your object you can get the data out of it and transfer it to a custom record attached to your symbol.

Link to comment

Take a look at the following thread for a sample script of how to attach a record to an object and grab data from the object attributes to populate the record.

https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=203171&Searchpage=1&Main=40740&Words=record&Search=true#Post203171

I agree with Hippothamus, if you can figure out a way to use the SPACE record directly rather than trying to use it in a database of symbols you would be much better off.

Link to comment

Thanks Pat and Hippothamus,

I'm not trying to schedule rooms here. I'm working on a project with 3 blocks some 15 cores, 2 towers, some 800 flats from about 100 types. Eventually I might want to list the rooms (by flat type not for the entire project obviously) and create marketing schedules but for the moment I'm just dealing with some planning schedule. The flat symbols exist already and the have a space for the flat area and a space for the external amenity space...

I've done some work on the script but it doesn't quite work, I think there might be more than 1 problem. I tried to follow your suggestions and had a look at other examples and the function reference, but as I said I'm not really good at code...

I've been able to set record field with a variation of what follows, but i'm probably doing something wrong with my variables here.

I tried changing the variable type for the flat area and thought I might have to use num2string or concat but I'm confused on the matter

A stripped down file with 1 symbol example, the script and a schedule is attached (VW2014)

Any help would be super welcome!

{Set the area of a SPACE contained inside a symbol to the Area Field of a record attached to such symbol}

Procedure Set_FlatSymbol_Areas;

Var

PlacedSymbol: Handle;

SymbolFlatArea : String;

Procedure Doit(ProcessObject :Handle);

CONST

symRecord = 'UnitID';

symFieldArea='Unit Area';

symFieldNo='Flat No';

spaceRecord = 'Space';

spaceArea = '11_Area';

Var

MyDefinition: Handle;

NestedObject: Handle;

SymDefName: String;

Begin

SymDefName:=GetSymName(ProcessObject);

MyDefinition:=GetObject(SymDefName);

If GetType(MyDefinition)=16 then

Begin

NestedObject:=FInSymDef(MyDefinition);

While NestedObject <> Nil do

Begin

If GetClass(NestedObject)='A-F90-M-Rent-Unit-2B' then

SymbolFlatArea := GetRField(NestedObject, spaceRecord, spaceArea);

NestedObject := NextObj(NestedObject);

End;

SETRFIELD(MyDefinition, symRecord, symFieldArea, Concat(symbolFlatArea));

End;

End;

Begin

ForEachObject(DoIt,((T=SYMBOL)));

End;

Run(Set_FlatSymbol_Areas);

Link to comment

I'm using an older vectorworks so I can't test it, but looking at your code:

When you use SetRField, you should use the symbol handle instead of the symbol definition handle. You are now changing the default value of the record in that symbol. Switch MyDefinition into ProcessObject.

If I'm correct you are also missing an "End;" closing the subprocedure doit.

How you search for the space object is up to you, if you are sure it has the right class this can work, might also search for an object type to rule out other objects you might have inside.

I'd add some more criteria to your foreachloop. For instance you can only loop symbols that hold the record you want to fill. This way you can have other symbols selected but they will be ignored.

loading and filling record values is a bit weird in vectorscript as you always get a string. As you mentioned you can convert them back to numbers at any point.

Link to comment

Thanks Hyppothamus!

I had to switch the handle for setrfield!

Everything else worked already. I wrote some indicative criteria as I felt I could refine them once the script was working.

I will try to add some IF in order to assign different field for different classes of the space. One for the GIA and one for the amenity.

Thanks Again for your help.

PS

My IT provided a different version of the script as follow...

PROCEDURE SpaceTest;

VAR

spaceObject: HANDLE;

parentSymbol: HANDLE;

parentSymName: STRING;

PROCEDURE DoSymbolUpdate(s: HANDLE);

VAR

spaceArea: DYNARRAY[] OF CHAR;

BEGIN

spaceArea := GetRField(spaceObject, 'Space', '11_Area');

SetRField(s, 'UnitRecord', 'UnitArea', spaceArea);

END;

PROCEDURE DoSpaceArea(spc: HANDLE);

BEGIN

IF spc <> NIL THEN

BEGIN

spaceObject := spc;

{ find the parent symbol }

parentSymbol := GetParent(spc);

WHILE parentSymbol <> nil DO BEGIN

IF GetTypeN(parentSymbol) = 16 THEN BEGIN

{ this is the enclosing symbol definition }

{ get the symbol def name }

parentSymName := GetSDName(parentSymbol);

{ traverse the drawing looking for symbol instances with the same name and update the field }

ForEachObject(DoSymbolUpdate, ((T = 15) & (S = parentSymName)));

END;

parentSymbol := GetParent(parentSymbol);

END;

END;

END;

BEGIN

{ step through the space objects that are inside symbols }

ForEachObject(DoSpaceArea, (INSYMBOL & (R IN ['Space'])));

END;

RUN(SpaceTest);

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...