Starting Out Help - Basic Question

Hi Guys,

I am trying to create a fairly straight forward script, but I am stuck. I have managed to tweak other user's scripts into versions that work for me but this one baffles me.

Basically I want the script to do the following:

Select ALL the helpers on a scene (names vary all the time), then DELETE all the selected helpers on the scene.

Can this be done via script?

I use Polytrans to import SolidWorks files and it always brings in a ton of "Helpers" that do nothing but complicate things.

The script will do other things, which I think I can muddle through.

Thanks a bunch,

Hernando

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
hernandoruiz's picture

I think I solved it.... I

I think I solved it.... I simply put the following at the begining of the script:

max hide object toggle
actionMan.executeAction 0 "40021" -- Selection: Select All

It turns off the geometry; it selects all, and then performs the cleanup. At the end of the scrips I simply repeat the:

max hide object toggle

And all is back per before without the dreaded "helpers"

Christpher a million thanks. I would never have been able to create or modify this script.

hernandoruiz's picture

Hi Christopher, Thank

Hi Christopher,

Thank you..... I have one issue with the script though. If I have existing "Groups" in the scene, after selecting "All", which includes the groups, I execute your script. What happens next is that my old Groups become ungrouped....

If I hide the "groups" and the select all, and execute the script. Everything works perfectly. Is there a way, via script, that I can select all my "Groups" only and hide them? Then something that will unhide the groups.

I really appreciate your help.

Thanks,

Hernando

Admin's picture

This was easier than I

This was easier than I expected. Its the same problem AutoCAD & Revit users have after importing - there are all kinds of useless helper/block/linkcomposite objects used to maintain the hierarchy. I've actually adapted Jon Seagull's DWG Cleanup script for our use here (orig script link http://www.scriptspot.com/3ds-max/dwg-cleanup)

It was really easy to change it for your purposes. Note - there is no undo (I deal with large files and having undo on caused quite a slowdown) and it operates on your selection so just import your solidworks file, select all and run this script.

Installation:
Maxscript / Run Script. You'll find it in the category "CAD Cleanup" and its called "Clean Solidworks import"

AttachmentSize
CAD Cleanup-Solidworks_cleanup.mcr 2.89 KB

Christopher Grant
Admin, ScriptSpot.com

hernandoruiz's picture

Hi Christopher, Here is a

Hi Christopher,

Here is a simple test file. You will see it has these dummy "helpers". Which are what I am trying to script. A typical file could contain 30 or more helpers.

Thanks a ton for your help and advice.

Hernando

AttachmentSize
helper-test.rar 83.02 KB
Admin's picture

Would it be too much trouble

Would it be too much trouble to attach a simplified file that has a couple of the objects / helpers in it? That way I could verify the script works then send back...

Chris

Christopher Grant
Admin, ScriptSpot.com

hernandoruiz's picture

They are "Dummy" helpers

They are "Dummy" helpers that are automatically created when I import a Soliworks assembly via Polytrans. They cause me a lot of trouble when trying to group object and the like. In addition to these dummy "helpers" I get the geometry objects which I need.

Thanks Christopher. I have combed the Help file without luck.

Hernando

Admin's picture

Its still totally doable via

Its still totally doable via script it'll just take a little bit more finesse.

What specifically are the type of helpers you want to delete?

Christopher Grant
ScriptSpot.com

Christopher Grant
Admin, ScriptSpot.com

Admin's picture

Hernando - welcome to

Hernando - welcome to ScriptSpot!

You can definitely do what you need with a script - and of course there are always multiple ways to do it...

To emulate the way the max UI would do it you could say

select helpers
max delete

However doing it that way will force a screen redraw when you don't want to do that... A more direct way would be to delete the objects directly. The delete command can take a variable, a selection of objects or even a class of objects. In this case - the object class are helpers so we should do this:

delete helpers

Word of warning - a "helper" class object is also a group head so if there are groups then those will be deleted as well. So we'd have to go about doing things a bit differently but for your simple case the single line above should work great.

Christopher Grant
ScriptSpot.com

Christopher Grant
Admin, ScriptSpot.com

hernandoruiz's picture

Thank you Christopher. I did

Thank you Christopher. I did not realize that selecting/deleting "helpers" would also select the groups.

Even if I turn off the groups before deleting the "helpers", the hidden groups get deleted as well.

This will present a big problem in my workflow.

I guess I will have to do it the manual way I always do. Where I open the "Selection" floater, deselect everything except "helpers", click on select all, close the floater, hit the delete key.

Thanks again,

Hernando

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.