Removing a percentage of elements from a TriMesh in MCG

Removing a percentage of elements from a TriMesh in MCG

Anonymous
Not applicable
3,439 Views
14 Replies
Message 1 of 15

Removing a percentage of elements from a TriMesh in MCG

Anonymous
Not applicable

So Hello everyone!

 

I'm currently creating an MCG to parametrically create shelves and an according amount of packets on them. There are equal amounts of the same packages in every compartment and are created separated from the shelves. So far most of it is working perfectly. But now I need to get rid of a specific percentage of random packages. I know that there is a script that does that with individual meshes, but since I'm using a CloneAndTranslate compound (which outputs a TriMesh), this wouldn't work properly. Also I want this to be an all in one solution without requiring a second script.

 

I've already tried a few different solutions (none of which worked at all), but due to the lack of proper documentation, all of those were shots in the dark. Is there a reference document were i can educate myself properly about all those operators in MCG? 

 

Does anyone have any suggestions?

 

 

0 Likes
Accepted solutions (1)
3,440 Views
14 Replies
Replies (14)
Message 2 of 15

Swordslayer
Advisor
Advisor

Since you are the one who controls creating the mesh, you should do that before creating the trimesh in the first place. Collect the transforms and pick the given percentage of them, then use those filteref transforms to clone meshes and attach the result. I've made a simple modifier that show the logic, only instead of mesh elements, you'd be shuffling transformation matrices:

 

deleteRandom.png

 

You can get it on scriptspot.

Message 3 of 15

Anonymous
Not applicable

First of all: Thank you.

 

This works perfectly for a single shelf. 

 

But now I'm encountering another problem:

Skizze.png

The Screenshot shows a high bay warehouse racking, created with my tool. It is fully procedural. the amount of boxes in each compartment depends on the size of the compartment and the spacing between the boxes. The amount of compartments depends on the size of each one and the overall size of the warehouse. But as you can see, if I duplicate them with the CloneAndTrasnform compound the shelves look exactly the same. I think I already know why this happens: the compound uses the "baked" result of the function (the TriMesh) but not the function itself. But i haven't found a workaround for this problem yet.

 

0 Likes
Message 4 of 15

Swordslayer
Advisor
Advisor

That's what you get by using cloning... A clean way would be generating the transforms in all three dimensions first, filter that result, then place meshes at those transforms and output final mesh. Dirty way would be filtering the resulting elements after cloning in all three dimensions (not before the last step as you do now).

Message 5 of 15

Anonymous
Not applicable

OK, I get what you mean. 

 

But I think I'm not able to put that into a graph. I am pretty new to this whole MCG thing (using it for about a week now). Maybe you could help me if i tell you how i create those racks?

 

So first of all i'm creating the first compartement, then i'm cloning it in the Z and aftewards in the Y direction. Then i'm filtering the boxes with the graph you povided (boxes and steel construction are generated separately). After that, the first aisle is created. then i clone that the calculated amount in the X direction to get multiple aisles. 

 

This was the easiest (read: only) way i found to do that.

0 Likes
Message 6 of 15

Swordslayer
Advisor
Advisor
0 Likes
Message 7 of 15

Anonymous
Not applicable

This seems to work only to a certain point... 

 

So if the warehouse does not exceed the size of around 50 meters x 25 meters (which it does in real world scenarios quite often) everything works just fine but if I go beyond that it takes a while  and then crashes. The maxscript listener shows the following:

 

Error occurred in HRL_Creator defined in C:\Users\user\Desktop\HRL_Creator.maxtool
- System.OverflowException, Array dimensions exceeded supported range. at Autodesk.Sequences.IArray`1[T] Flatten[T](Autodesk.Sequences.IArray`1[Autodesk.Sequences.IArray`1[T]])
   at Autodesk.Sequences.ImmutableArray.Flatten[T](IArray`1 seqs)
   at Autodesk.Geometry3D.MeshData.IndirectChannel`1.Concatenate(IArray`1 channels)
   at Viper3dsMaxBridge.MaxMeshData.Concatenate(MeshData[] xs)
   at Viper3dsMaxBridge.ViperMaxOperators.TriMeshOps.CombineAllMeshes(IArray`1 meshes)
   at _anonymous_type_58.main(<16 parameters used prior>) in C:\Users\user\Desktop\HRL_Creator.txt:line 721

The referred line (721) shows a Combine all meshes operator:

 

_200CombineAllMeshes = CombineAllMeshes(_199Take);

So do too many input parameters generate more dimensions than a 3ds max array can handle?

Message 8 of 15

Swordslayer
Advisor
Advisor

Yeah, that's sort of a known MCG error 😕 You know what? Could you post that along with the error message to the facebook 3ds Max Procedural Tools - MCG + DCM group? The MCG developers frequent it and could be able to help or at least promise some solution in next service pack.

Message 9 of 15

Anonymous
Not applicable
Accepted solution

Finally after some days of trial and error, but more important, lots of help from here and that facebook group, I was finally able to get a solution to this problem. The source of the error was the MeshElements node, because, as it seems, this isnt able to take more than ~3800 elements at once. solution to this: Splitting the whole Array of meshes into vertices, then slice the array by the amount of vertices in one object into subarrays. Then I'm using most of the script posted above to remove a certain percentage of objects and shuffle the array.

 

Picture below shows the whole process. The upper TriMesh input is the array, the other two are the base object.

 

Unbenannt01.PNG

Message 10 of 15

Alfred.DeFlaminis
Alumni
Alumni

Thank you very much for posting the follow up @Anonymous, that was very nice of you.  Kudos to you, sir!   Nice work in this thread @Swordslayer!

 

Best Regards,

0 Likes
Message 11 of 15

PiXeL_MoNKeY
Collaborator
Collaborator

SwordSlayer's method is good, but I know I ran into a few issues with being able to produce repeatable results. 

 

If you are trying to get random elements from an Array I found that Vu_RandomUniqueFromArray provides consistent repeatable results. Vu's results will flip over 50 percent for performance reasons, but that may be able to be fixed with an If greater than 50 percent call to fix it.

 

NOTE: There may be some missing compounds in there. I have them from another file I downloaded, but don't remember where I found it. I will see if I can link you to that file later.

 

-Eric

Message 12 of 15

Alfred.DeFlaminis
Alumni
Alumni

It's great to see you in here @PiXeL_MoNKeY, thanks for the informative post.  When I was just learning 3D to beyond a beginner level, you were the person who helped the most with my various questions and problems I was having.  I don't think I ever got a chance to say thank you for that.  You really helped me a lot over the years and I have not forgotten, thank you.

 

Best Regards,

0 Likes
Message 13 of 15

PiXeL_MoNKeY
Collaborator
Collaborator

Thanks Alfred I hope I can get back to having time for more forum helping.

 

It took some download and URL history forging, but I finally found the other Vu post with the needed missing compounds in his test_ADistanceB.mcg found in the FB posts here.

 

-Eric

0 Likes
Message 14 of 15

projectnandlastrategy
Explorer
Explorer

To remove a specific percentage of random packages in MCG, integrate a Random Selector or Condition Filter into your graph to control the output of the CloneAndTranslate compound. For detailed guidance, refer to Autodesk’s official MCG Help or the Area by Autodesk forum. Let me know if you'd like further assistance!

0 Likes
Message 15 of 15

MartinBeh
Advisor
Advisor

The Array modifier also allows to remove a random percentage. Just saying...

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes