Jump to content
Developer Wiki and Function Reference Links ×

Automatically Generate 3D Building from Polygon on Specific Layer


Yaro

Recommended Posts

Hi all,

I'm relatively new to working with Marionette in Vectorworks, but I'm looking to create a script that will automatically generate a 3D model when I draw a polygon on a specific layer.

 

What I'm trying to achieve:
Whenever I draw a polygon on the layer ‘detached house’, it should immediately create a 3D building with the following specifications:

- 2 floors of 3 meters each

- A pitched roof (1.5 meters high)

- The roof should slope along the length of the building

 

So ideally, the Marionette script would detect the polygon on the right layer and directly generate a full 3D object with these parameters.

Has anyone here done something similar, or could point me in the right direction?
Example scripts or hints would be greatly appreciated!

 

Thanks in advance

Link to comment
16 hours ago, the frog said:

Hello

This is what  you get 2 floors and the roof. Of course it's possible to fill the roof.

The easy way is to send a vw file with the result you want. This way it's possible to help.

screen.png

Hi,

 

Thanks so much for your response!

 

Yes, something like what you showed would be perfect. I’ve attached a file containing the different housing types and the standard building forms.

 

A few important details for the script logic:

 

I draw a 2D polygon on a specific layer, for example “detached housing”.

 

When I run the script, a 3D model is generated based on the polygon’s footprint (length and width), with the following structure:

- 2 floors, each 3 meters high

- A pitched roof, sloping along the length, and 3 meters high

- So for example, if I draw a polygon of 3x6m, the building should also be 3x6m at the base, with the height automatically generated based on the above logic.

 

The script should read the active layer to determine the housing type and generate the correct 3D form accordingly (e.g., apartments vs detached housing).

 

Does this make sense?

 

Thanks again for your help!

Document with standard 3d models of housing types.vwx

Link to comment

Got the idea 

You spoke about polygons, are they all four sided or rectangle only?

Do you want to see the separation between the floors?

Do you need to choose with or without roof?

In you first post you said the roof was 1,5m now the high has to comply with the number of floors (1 level 1,5m 2 levels 3m etc…), or do you want to be able to specify the roof high?

Only the first questions before writing the script

Link to comment
13 hours ago, the frog said:

Got the idea 

You spoke about polygons, are they all four sided or rectangle only?

Do you want to see the separation between the floors?

Do you need to choose with or without roof?

In you first post you said the roof was 1,5m now the high has to comply with the number of floors (1 level 1,5m 2 levels 3m etc…), or do you want to be able to specify the roof high?

Only the first questions before writing the script

- Yes, I'm currently using rectangles only, but it would be helpful if polygons were supported as well, since sometimes an apartment block might need to have a special corner or shape.

- Yes, please.

- Not really. I mean, in the future it would be nice to have the option to choose which types of roofs can go on which buildings, but it will take me some time to figure that out. And for now that isn't important. If you could help me with the basics in the meantime, that would be incredibly helpful.

- No, that was my mistake, the roof should be 3 meters. Eventually, it would be great to have the option to adjust the roof height, but that’s not a priority right now.

Link to comment
11 hours ago, Jonathan Pickup said:

this might help

 

Thanks for your reaction, Jonathan! That’s essentially what I need. However, I’m looking for a script that can do multiple houses at once, each with different diameters. It’s just way more efficient to do it through a script. (which I haven’t been able to figure out yet on how to do that) 🙂

Link to comment
2 minutes ago, Yaro said:

Thanks for your reaction, Jonathan! That’s essentially what I need. However, I’m looking for a script that can do multiple houses at once, each with different diameters. It’s just way more efficient to do it through a script. (which I haven’t been able to figure out yet on how to do that) 🙂

 

Another option is Create Objects from Shapes... > Massing Model. Will create multiple buildings at once based on the selected polygons + the height/roof/floor parameters you tell it to use.

Link to comment
2 hours ago, Tom W. said:

 

Another option is Create Objects from Shapes... > Massing Model. Will create multiple buildings at once based on the selected polygons + the height/roof/floor parameters you tell it to use.

Hi Tom,

 

Thanks for your response. This will definitely be helpful to get started. However, my ultimate goal is to develop a script that allows for quicker adjustments by simply placing objects into the correct layers.

 

For example, detached housing would be organised into multiple layers based on roof types, which I could then easily modify. I believe this could work using "Create Objects from Shapes," but I still feel there might be a more efficient way to handle it with a script. That said, I might be wrong.

  • Like 1
Link to comment

I have been watching this thread.  House from polygon tweaked my interest, but I am not a Marionette person.  But, if I had to do something like this "old school" I would use the Multiple Extrude tool.  Perhaps instead of a polygon house, a polygon(S) house would be easier to script.  

 

See below for an example of how I would do this.

 

 

Link to comment
  • 2 weeks later...

Hello

Thanks to Marissa (the copyName problem), after digging into your question, here is a possible solution.

 

In the VW network, you have the developed script (to see the way it’s built) and the enveloppe one.

The script works with rectangles and 4 sided polygons.

I kept your layers names and added a “specific“ one where the script is written.

1-    To make the script work you need to choose the layer you want the building to be. THE LAYER DEFINES THE NUMBER OF FLOORS AND THE TYPE OF HOUSING.

2-    Second you draw your e.g: rectangle where you want it on the plan.

3-    You give a name to the rectangle (bottom of the OIP)

4-    You run the node. A dialog box will open where you copy the name you gave to your rectangle

5-    Magic it returns a 3d model with the parameters (number of floors, roof type, layer) you asked in your post.

6-    If you are in a different layer when you draw the rectangle and change the object layer, the result will be seen on the chosen layer AND will become the active one.

7-    If you copy a 3d group, its name will increase by one. Remember that a name is unique in VW never give twice the same name or it will return the Marionette node number

 

If you are not happy with the ceiling  high  (now 300 cm) dig in the script, the “real”node name is “ceiling hight”.

If you want to change the number of floor parameters e.g: a “Detached house is built with 2 stories you need to change at the beginning of the scrip the “param” value AND open the “floor_number_decision” enveolppe node to modify  inside the chosen layer enveloppe node, the “int” number (number of floors, always smaller or equal to the “param”).

For the name buildings and shapes I choose, you might recognize the Hague addresses (thanks to Google earth)☺️Capturedecran2025-08-16a18_58_11.thumb.png.a37a38f8ff9fddab3452905d1dd7a1a5.png

building by layer V1.vwx

Edited by the frog
Link to comment

Here is a debugged version (false 2d restitution)  + the "terrasse" roof added. This version allows you to choose in the OIP, the ceiling high, the roof typology, and the numbers of level before the object is considered apartments with no roof.

There is still a bug with the double roof, it won’t take the attribute and stays colored (VW mystery).  The Enveloppe  node won’t return the 3d name, that’s why you have the last node attached.

If you run the developed script, once you’ve put back in the last node, it works.Capturedecran2025-08-18a18_46_19.png.a19c1dfb456b4a9311c555fba16f407f.png

buiding by layer V2.0.vwx

  • Love 1
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...