Function or Script to help eliminate extra imported geometry

Function or Script to help eliminate extra imported geometry

Anonymous
Not applicable
1,218 Views
10 Replies
Message 1 of 11

Function or Script to help eliminate extra imported geometry

Anonymous
Not applicable

Hello-

 

I have recently been working on exporting data from the molecular viewer Pymol into 3ds max. The data is saved as Vrml files in Pymol and imports fine into max. However, I have noticed that extra geometry is imported. For example, whenever there is a chemical bond, anywhere from 1-4 spheres are located at that bond in the imported file when only 1 is necessary. As you can imagine, this is blowing my polycount through the roof.

 

I have tried to figure out a way to prevent the extra spheres from being saved out of Pymol, but have been unable to find a solution. So far I have been going through and deleting the extra spheres by hand in order to get my polycount low enough for the eventual rigging and animation of my models.

 

I was wondering if anyone happens to know of a function or 3ds Max script that could fix the extra geometry problem for me and save me lots of time in the modeling component of my current project.

 

0 Likes
Accepted solutions (1)
1,219 Views
10 Replies
Replies (10)
Message 2 of 11

Swordslayer
Advisor
Advisor

You'd have to give a bit more information, are the spheres exact duplicates (or at least same position plus same size) or what is it that makes them extra?

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

Thank you for your swift reply!

 

The model is imported as a series of open cylinders and spheres that act as joints (or bonds if you were to think of it chemically) between each cylinder. In some places, no spheres are necessary (for example, when the open ends of the cylinders are flush to each other and there is no angle where the two meet), and in other areas (where the cylinders meet at an angle) a sphere is necessary to represent the bond. However, in those areas where the cylinders meet at angle, there is not one sphere, but 2-3 spheres in the same exact location. Every sphere in the scene is the same size.

 

I plan on combining the spheres and cylinders to create my overall model, but only need one sphere where the cylinders meet at an angle, rather than 2-3. As I mentioned earlier, the ends of each cylinder are open, so without the spheres at the angled intersections, there would be gaps in my model. I know I could fix that by combining the cylinders and bridging the gaps, but keeping a single sphere where the cylinders meet at an angle and simply combining the objects seems like a swifter solution.

 

So far I have been selecting all the spheres in the scene, deselecting the ones necessary for my model, and deleting the extra spheres selected to reduce my poly count. These selected spheres that are deleted are all spheres but one where the cylinders meet at an angle, and all spheres where two cylinders meet and are perfectly flush.

 

I have included a jpeg of a small portion of the model to help illustrate what I'm talking about. I can also include a small sample of my file if that would be more helpful.

 

I am using 3ds Max 2014.

0 Likes
Message 4 of 11

Swordslayer
Advisor
Advisor
0 Likes
Message 5 of 11

Anonymous
Not applicable

Attached is the .obj file you requested. This represents a small portion of a single chain that I imported as a VRML. The original imported chain without any edits (containing all the extra spheres) is about 4,200,000 polys. My complete scene contains about 15 full chains. 

 

 

 

 

0 Likes
Message 6 of 11

Swordslayer
Advisor
Advisor
Accepted solution
0 Likes
Message 7 of 11

Anonymous
Not applicable

Swordslayer,

 

The script works perfectly! Thank you so much for your help, you just saved me hours and hours of extra work. I really appreciate it.

 

Just for personal edification, is there a function in max that could work similar to the script you created? Or was creating a script the only option for my situation?

 

Thanks again!

0 Likes
Message 8 of 11

Swordslayer
Advisor
Advisor

There's no built-in function I'm aware of, your situation is pretty specific. Consider marking the thread as solved if it there are no other issues, too 😉

 

0 Likes
Message 9 of 11

Anonymous
Not applicable

Swordslayer, 

 

The script works perfectly on the smaller sample file that I posted. However, whenever I try to run the script on my larger models  the script does not load. One scene contains 15 chains (coming to over 32 million polys) total while another contains a single chain (amounting to about 14,200,000 polys). When I try to run the script, 3ds max simply shuts down, or acts like it is loading the script but never does. I tried running the script on the scene that contains only one chain and left it to load while I went out and did some errands yesterday, but it still hadn't loaded when I got back several hours later.

 

I suspect this may simply be due to the size of the scenes, but thought I may mention the issues with the larger scenes in case there are any specific aspects of the script that are dependent on the state of the scene. I do not know why that would be the case, but I have minimal experience with MAXscript so thought I would ask out of curiosity. In your experience is there a specific threshold concerning scene size (for example a ballpark polycount) where scripts do not work as efficiently or fail to load in 3ds Max? 

 

As it is, the script is still a huge help. An easy solution would be to simply break down my chains into smaller pieces and run the script on these smaller portions and combine them later. Thanks again for your feedback and help!

0 Likes
Message 10 of 11

Swordslayer
Advisor
Advisor

Search the script for gridUnit:1.0 and in both cases try increasing the unit size; what does objects.max - objects.min return when evaluated on your scene? I.e. how big it is?

0 Likes
Message 11 of 11

Anonymous
Not applicable

When I ran objects.max - objects.min, I got the following: 

 

[11741.7,16286.6,8806.31]

 

This is from a  scene where I have imported all 15 chains and reduced the polycount of 14 of the 15 chains by manually deleting the extra spheres. 

0 Likes