question

Chandler avatar image
0 Likes"
Chandler asked Chandler edited

How to create a node with simple data type? (to create walls with flexscript)

I am creating a script that draws walls from a list of XYZ coordinates and a list of pairs of indices to connect. I am trying to create a simple data node to get to my ends and I need a method in flexscript.

Context is provided below:

----

I can import my CSV in script, I can create the Pillars in script by leveraging the ability to set "up" on an object like this:

for (int index = 1; index <= coords.numRows; index++)
{
Array pH = [];
for (int coord = 1; coord <= 3; coord++)
{
pH.push(coords[index][coord]);
}
treenode currDiv = Object.create("People::Walls::Pillar").setLocation(pH[1],pH[2],pH[3]);
string pillarName = "Pillar"+index;
Object currPillar = currDiv;
currPillar.setProperty("Name",pillarName);
currDiv.up = Model.find("/Walls>visual/drawsurrogate");
}

Now I need to create a wall from the script. I intend for this to be a simple solution for any future users. I could draw a wall and copy the node, then modify its values - but that's roundabout.

So as far as I can tell I just need to create a simple data node with the correct structure. I can create a subnode using treenode.subnodes.assert(), but when I try to use treenode.dataType(7) (or any other number) on the resulting node, I get an "Unknown command dataType being called" error.

The best solution in my opinion would be if I can directly draw a wall using the indexed name of existing pillars. If that is possible, can someone please tell me how to create that node and where I would be able to look to find information about how to create that node?


Or am I going about this wrong? I understand flexscript at a beginner/intermediate level, but my knowledge of C++ is pretty limited so I am looking for a solution in flexscript.

(Note: I have a similar script working for A* dividers but it simply uses the object create for each one and then resets the X,Y,Z variable values for each end. That's not an option for walls unless I can directly make a wall with script, but I assume that the ability to do that would mean that I initially assign Pillars and wouldn't need to do a "create and move" sort of thing)

FlexSim 23.1.0
flexscriptwallsdrawingsimple data
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot commented

You should instead use the function_s call in flexcript:

  1. Object walls=Model.find("Walls");
  2. Object pillar3=Model.find("Walls").find(">visual/drawsurrogate/Pillar3");
  3. Object pillar4= Model.find("Walls").find(">visual/drawsurrogate/Pillar4");
  4. function_s(walls,"addWall",pillar3,pillar4);
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Chandler avatar image
0 Likes"
Chandler answered Chandler edited

This is not an answer to the question asked, but is an answer to the problem that I explain in the post:

If anyone finds this question and is looking for a solution to create walls in such a way, I have a working script that will create walls from 2 separate CSV files (XYZ points and a mesh edge topology in the form of ordered pairs of indices) in the model directory and create walls at those coordinates. Please contact me here and I will try to help. I don't want to provide it outright because I can't guarantee it will work.

If you are working from a Revit model and export a CAD file, the coordinates would be the same ones that are used in the CAD file, so a CAD background will line up perfectly with the walls.


Currently function is limited to destroying the existing walls object and creating a new one in its place. I think this is necessary because the pillars have to be indexed correctly for the whole thing to work. I am using Grasshopper and Rhino.Inside.Revit to process my walls, and will comment here if I have found a better way in the future. (Dynamo was proving clumsy and my coding ability is not quite there yet to write my own component)

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.