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:

Object walls=Model.find("Walls");
Object pillar3=Model.find("Walls").find(">visual/drawsurrogate/Pillar3");
Object pillar4= Model.find("Walls").find(">visual/drawsurrogate/Pillar4");
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 Chandler commented ·
This looks like it would solve my issue. Thanks! I'm going to try to edit the question to clarify what has been answered here.


Is "addWall" a function in the definition of the "Walls" object? Is there somewhere in documentation that I would be able to look up those functions?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Chandler commented ·

You'll find such functions in the library tree of the relevant object.

The issues are:

1) They're not documented - you either need to find how they work by trial and error or find examples within the FlexSim environment (GUIs, menus etc).

2) They're not supported - FlexSim developers could at any point rename, remove or alter the methods causing user development to fail or require updates (that's why I'd recommend you create your own user commands that call function_s rather than put them throughout your model - then you can edit/repair them in one place.

3) It could make your models behave incorrectly if used without full understanding of their operation and therefore introduce delays for debugging and further support (which may be limited dues to the use of such functions).

So if there's a way to avoid using them that's probably preferred.

Also you might want to question if the Walls object does everything you need and if not create your own. For example I don't think it works with nested /containers /hierachical models so if you think you might want that, you might be better creating something yourself that draws the required meshes for your wall structures.


0 Likes 0 ·
Chandler avatar image Chandler Chandler commented ·
Also, how would I go about making a simple data node if I needed to? Is that generally not useful? Regardless, shouldn't treenode.dataType(7) work?
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Chandler commented ·

I'm not sure about your syntax but changing the data type to DATATYPE_SIMPLE works in itself:

mynode.dataType=DATATYPE_SIMPLE;

but there's more to getting the set of required values on the node.

0 Likes 0 ·
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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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