Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combined VBscript

Status
Not open for further replies.

Jetsetter

Aerospace
Sep 29, 2007
22
0
0
US
Is there a way to combine a hide / show operation for points, lines, planes, axis systems, basically all ref geometry into one script so all i have to do is create one icon? The script in the ref thead helped me considerably and I thank all that contributed.

thread560-172343
 
Replies continue below

Recommended for you

I'll start by noting that I am a complete novice to scripting, but I do have a working solution to what you describe. This is a catvbs script that switches off axis systems, planes, and assembly constraints in one click.


Language="VBSCRIPT"

Sub CATMain()

Set productDocument1 = CATIA.ActiveDocument

Set selection1 = productDocument1.Selection

selection1.Search "CATProductSearch.MfConstraint.Visibility=Shown,all"

Set visPropertySet1 = selection1.VisProperties

visPropertySet1.SetShow 1

selection1.clear

Set selection1 = productDocument1.Selection

selection1.Search "CATPrtSearch.AxisSystem.Visibility=Shown,all"

Set VisPropSet1 = Selection1.VisProperties

VisPropSet1.SetShow catVisPropertyNoShowAttr

selection1.clear

Set selection1 = productDocument1.Selection

selection1.Search "CATPrtSearch.Plane.Visibility=Visible,all"

Set VisPropSet1 = Selection1.VisProperties

VisPropSet1.SetShow catVisPropertyNoShowAttr

selection1.clear

End Sub

I only worked the script to a point that it works, but along the way I discovered a few things. There are shown/hidden attributes, as well as visible/invisible. You can set the show attribute to 0 / 1, or to catVisPropertyNoShowAttr / catVisPropertyShowAttr. I haven't dug deep enough to really understand the implications of all this.

I have been told by a coworker that modifying the script to select only elements that are on the screen, rather than searching for all shown, speeds the process considerably. That would be to change the search criteria from "all" to "scr." But, I haven't gotten around to updating the script.

I would welcome any suggested improvements to this :)

Cheers,

Mark
 
Thanks Mark...Just before you replied I found an earlier thread from 2006 that had the script. I too am new to this but adapting very quickkly. thanks again.
 
Now Ive got a new problem...I create the macro..then create my tool bars. When i close catia and start a new session..all of my scripts are gone and all of my created toolbars are gone from the screen and in the toolbar list. anyone know why?
 
Well, there are a lot of things to tell about this subject...

Maybe in your network is existing a maintenance script which delete all CATSettings (CATIA will create new ones at the next start-up automatically). In this case, for sure you lost all your new created toolbar and assigned icons.

Where did you save the macros? If your administrator decided to delete all "unauthorized" folders,they are gone also.

You know how it is, each company with own rules...

Regards
Fernando
 
I think I found the problem after my major loss of scripts...I think they were being saved to a local temp directory and when restarted the temp directory is cleared. So i created a folder on my C: drive to store my scripts and it seems to be working ok for now but...we will see when i come in on monday.
 
Ok it seems to be working after shut down and startup also after a reboot. Does it really matter where you store your script folder? I guess it doesnt have to be within the catia folders as long as catia can read from it. Well anyway...problem solved for now.
 

It doesn't matter where you store the settings, so long as you don't put them somewhere that gets regularly deleted.

Also, it is important to note that some companies create (as part of the startup) a script which deletes CATSettings upon each start, or otherwise points the user to a pre-defined CATSetting directory. This is especially true for SmarTeam and Enovia users. The workaround is just to create your own environment that points to the same place, but without the extra code.

-----------------------------------------------------------
Catia Design|Catia Design News|Catia V5 blog
 
I would have some reserve on what Solid7 said:
Also, it is important to note that some companies create (as part of the startup) a script which deletes CATSettings upon each start, or otherwise points the user to a pre-defined CATSetting directory. This is especially true for SmarTeam and Enovia users. The workaround is just to create your own environment that points to the same place, but without the extra code.
You should talk to your CATIA team and see with them what is the best way to have your code available. If you by pass your default environment you might create parts that might not be in the company standard.

Eric N.
indocti discant et ament meminisse periti
 

I'm not suggesting that my method is for everyone - but I also didn't say to bypass the default environment. I have a tendency to clip any scripting which wants to delete my user settings, while still pointing to the default environment. (or I create a new target to the standard environment) While it is handy for IT and admins to delete settings, on the premise that they MAY corrupt, and cause unnecessary phone calls, I still believe that the greater evil is restricting a user's preferences which may lead to gains in proficiency and/or productivity. It is overkill to default back to the original CATSettings, just for the sake of doing so, on every fresh start. (and highly annoying)

When I have problems, I just delete my CATSettings and try again before I make the phone call. There are never any issues beyond that.


-----------------------------------------------------------
Catia Design|Catia Design News|Catia V5 blog
 
Status
Not open for further replies.
Back
Top