Jump to content
Developer Wiki and Function Reference Links ×

multistory building vs. space number vs. me


Recommended Posts

Hi

once a year I try to produce a script.

 

This time I tried the following:

 

got an multistory ifc file from an architect with spaces

imported the file using  story as layer

placed objects into the spaces

tried to push the space number into an attached database with the help of the data manager using the "=getspacenumforobj

failed because I receive every space below and every space on top as well. 

 

so my idea was use a script that works on active objects on the active layer only and uses that as criteria.

 

sounds easy BUT...

 

can anybody point me in the right direction? 

 

PROCEDURE WriteSpaceNumToDatabase;
VAR
    h : HANDLE;           { Handle für aktivierte Objekte }
    spaceNum : STRING;    { Raumnummer }
    objLayer : STRING;    { Ebene des Objekts }
    activeLayer : STRING; { Aktive Konstruktionsebene }
BEGIN
    { Holen Sie sich den Namen der aktiven Ebene }
    activeLayer := GetLName(ActLayer);

    { Gehe durch alle aktivierten Objekte auf der aktiven Ebene }
    h := FActLayer;  { Erstes aktiviertes Objekt auf der aktiven Konstruktionsebene }
    WHILE (h <> NIL) DO
    BEGIN
        { Holen Sie sich den Namen der Ebene des aktuellen Objekts }
        objLayer := GetLName(h);

        { Überprüfen Sie, ob das Objekt auf der aktiven Ebene ist }
        IF (objLayer = activeLayer) THEN
        BEGIN
            { Holen Sie die Raumnummer für das aktuelle Objekt }
            spaceNum := GetSpaceNumForObj(h);

            { Wenn eine Raumnummer vorhanden ist, in die Datenbank schreiben }
            IF (spaceNum <> '') THEN
            BEGIN
                { Schreibe die Raumnummer in die Datenbank "Objekt" ins Feld "Raum" }
                SetRField(h, 'Objekt', 'Raum', spaceNum);
            END;
        END;

        { Nächstes aktiviertes Objekt auf der aktiven Konstruktionsebene }
        h := NextSObj(h);
    END;
END;

RUN(WriteSpaceNumToDatabase);

 

 

Link to comment

I don't have a file where I can test it on, but looking at the script, there are several things where this can fail:

SetRField(h, 'Objekt', 'Raum', spaceNum);

This will only work if the record "objekt"' is already attached to the object.

This will also only work if that record has a field called "Raum".

 

So you need to attach the record first.

SetRecord( h, 'objekt' );
SetRField( h, 'objekt', 'Raum', spaceNum );

 

And if the record doesn't exist in the document yet, you need to create that first too.

 

This is all without testing, so I might have missed something else too.

Link to comment

Hello @Thomas K.,

 

I haven’t been active here for very long and I’m more focused on Marionette. So if I’m completely off track, feel free to give feedback if I’m talking nonsense 🙂.

 

Room Database:

I found out that the database is called “Space” and the field entry for the room number is “11_Number”.

I was also able to access and change this room number with a small Marionette script, so I think it’s the correct row.

I’m working with Vectorworks 2023. No guarantee that it’s the same in other versions.

With Marionette, I could imagine mapping this relatively easily. But I’m not that far with pure code yet 😄.

 

Suggestion:

I would play around with GetRField

The objects I insert would have a database connected “RoomDB”.

During the run, I would first search for the object that has the database “Space” linked and field “11_Number”.

If it is found (the room), I would pull the “11_Number” value and then run through all objects again and search for objects with “RoomDB”.

I would then pass the “11_Number” value to these objects.

After this, you would of course need to END and not return to the first loop.

 

If there are multiple rooms and objects, you could also try to automate the “active” objects.

But of course, it strongly depends on what else is on the layers.

 

I think you can better judge whether this can work as a script. I would map it similarly in Marionette.

 

Good luck

Link to comment

I didn’t work cleanly there, sorry 😄.

 

setRField would of course be the syntax for assigning the database. It would also not be necessary to link the inserted objects with the “RoomDB” beforehand.

In the second loop, you could also assign “RoomDB” to all objects.

You might consider excluding the actual room, but you could also use it to pass additional characteristics to the room for other purposes.

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