aachman98 / Sorcar

Procedural modeling in Blender using Node Editor
https://aachman98.itch.io/sorcar
GNU General Public License v3.0
1.16k stars 112 forks source link

[REQUEST]Create node to save node info in a python variables #148

Open automataIA opened 4 years ago

automataIA commented 4 years ago

A node that take info from model(volume, name, surface, coordinates) and save in a python variable. Then use this variable in a python script and resend the output info to sorcar

aachman98 commented 4 years ago

Is creating a separate variable for mesh a necessity? If not, then you can directly access the object's data using obj.data (which returns the mesh). Otherwise, you can get the current mesh info by using BMesh (https://docs.blender.org/api/current/bmesh.html). Before the end of the script, you can push changes to the currently active object (in the context). The "Custom Python Script" node allows you to run a single line code or a script (Text Box input) while providing sockets for "In" and "Out" where the object reference can be passed.

Maybe I can provide you with an alternate approach if you can let me know the use case. Most of the times, you'd want to operate on the geometry directly, without copying its data.

automataIA commented 4 years ago

Example : im creating a concrete frame( beam, column are solid). I need to create a wall between this beam and column. Then i need all information from this 2 elements(like coordinates and orientation), for resend this variables information in a another sorcar page. Becaouse i need 1 sorcar page for 1 element( wall, beam etc...)

aachman98 commented 4 years ago

There a couple of nodes that can help you with transfer of information form one nodetree to another: "Get Variable" and "Set Variable" nodes

Use "Set Variable" node in a nodetree and pass the created object in as value: Screenshot from 2020-06-06 03-22-05

Then use the "Get Variable" node to get that object reference and either access it directly, or get its information like this: Screenshot from 2020-06-06 03-24-18

It will save some performance by not duplicating the mesh to a variable.