Possible Macro or Catia Setting
Possible Macro or Catia Setting
(OP)
This is to address multiple issues I am running into.
If anyone can answer either part of them it would be appreciated.
1.When I open a step file sent to me from another 3D modeling program, it comes in as a single part with multiple bodies.
I know in Creo, I can choose to import the step file as parts or assemblie, is there a way to do this in Catia V5?
2.If this in not possible in Catia, is there a Macro that can rename the part bodies or at least remove symbols that are not allowed in part names, like "/" and "."?
I already have a macro that will split out each part body into parts and create a product out of it, but it fails when there are "/" or "." in the part body names.
If anyone can answer either part of them it would be appreciated.
1.When I open a step file sent to me from another 3D modeling program, it comes in as a single part with multiple bodies.
I know in Creo, I can choose to import the step file as parts or assemblie, is there a way to do this in Catia V5?
2.If this in not possible in Catia, is there a Macro that can rename the part bodies or at least remove symbols that are not allowed in part names, like "/" and "."?
I already have a macro that will split out each part body into parts and create a product out of it, but it fails when there are "/" or "." in the part body names.





RE: Possible Macro or Catia Setting
Check in Tools-Options-General-Compatibility-STEP-Import-One CATProduct for each product
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Possible Macro or Catia Setting
When i pull it into Creo 3.0 and select assembly, it brings it in as an assembly.
RE: Possible Macro or Catia Setting
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Possible Macro or Catia Setting
If anyone could give me a start as to how to write it, that would be appreciated.
RE: Possible Macro or Catia Setting
post your code in progress, I'll help.
indocti discant et ament meminisse periti
RE: Possible Macro or Catia Setting
RE: Possible Macro or Catia Setting
Currently I am just trying to replace a "." with a "_" in the first body. Once I figure this out, Ill try and get it to continue this on the other bodies in that part.
CODE -->
I ran this on a single part body part and it gave me the error message that it failed at "End Sub" and it did not replace the "." with a "_".
RE: Possible Macro or Catia Setting
RE: Possible Macro or Catia Setting
in your catia installation you'll find a catiav5automation.chm file (or something very similar but still .chm) check the structure of the part object. You should find a Bodies collection in the part object
if you do something like
CODE --> vba
indocti discant et ament meminisse periti
RE: Possible Macro or Catia Setting
CODE --> VBA
Sub FixPartBodyNames() Dim myPart As Part Set myPart = CATIA.ActiveDocument.Part Dim myBody As Body Dim newName As String Dim newCharacter As String newCharacter = " " For Each myBody In myPart.Bodies 'loop through all the bodies in the part newName = myBody.Name 'get the current body's name newName = Replace(newName, ".", newCharacter) 'replace all "." with "_" newName = Replace(newName, "/", newCharacter) 'replace all "/" with "_" newName = Replace(newName, "\", newCharacter) 'replace all "/" with "_" newName = Replace(newName, " ", newCharacter) 'replace all "/" with "_" newName = Replace(newName, "*", newCharacter) 'replace all "/" with "_" newName = Replace(newName, " ", newCharacter) 'replace all "/" with "" myBody.Name = newName 'rename the current body with the revised name Next MsgBox "All Done!" End SubThis does exactly what I want it to do, except I would like it in CATScript.
I am very new to coding and am struggling to figure out how to rework this to run in CATScript.
RE: Possible Macro or Catia Setting
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Possible Macro or Catia Setting
Here is the updated code for anyone to use in the future:
CODE --> CATScript
Sub CATMain() Dim myPart As Part Set myPart = CATIA.ActiveDocument.Part Dim myBody As Body Dim newName As String Dim newCharacter As String newCharacter = " " For Each myBody In myPart.Bodies 'loop through all the bodies in the part newName = myBody.Name 'get the current body's name newName = Replace(newName, ".", newCharacter) 'replace all "." with "_" newName = Replace(newName, "/", newCharacter) 'replace all "/" with "_" newName = Replace(newName, "\", newCharacter) 'replace all "/" with "_" newName = Replace(newName, "*", newCharacter) 'replace all "/" with "_" myBody.Name = newName 'rename the current body with the revised name Next MsgBox "All Done!" End Sub