Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

macro to save multiple parts in a desired format (3d xml, stp ) 2

Status
Not open for further replies.

pravs

Mechanical
Apr 12, 2018
34
Hello
While using the code given in the Macro to rename and save all unique parts in a product an error regarding 'save as' pops up .
can someone post generalized macro to save cat parts , cat products etc in desired formats like 3dxml , stp etc.


Option Explicit
Sub CATMain()
Dim iCount As Integer
Dim sSuffix As String
Dim sNewName As String
sSuffix = "_00"

'To avoid save as warnings*********
CATIA.DisplayFileAlerts = False

Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product
Set product1 = productDocument1.Product
Dim doc1 As Document
Dim products1 As Products
Set products1 = product1.Products

For iCount = 1 To products1.Count
products1.Item(iCount).PartNumber = products1.Item(iCount).PartNumber & sSuffix
sNewName = products1.Item(iCount).PartNumber
Dim documents1 As Documents
Set documents1 = CATIA.Documents

iCount = iCount + 1
Set doc1 = documents1.Item(iCount)
doc1.SaveAs " C:\Users\kpravars\Desktop\test\" & sNewName & ".CATPart"
iCount = iCount - 1
Next iCount
End Sub

my task requires me to just save all the catparts and catproducts in a given installation locally in the specific folder (preferably in STP format).
thanks in advance .
 
Replies continue below

Recommended for you

Hi,
the problem is as shown in the image I need to save all the parts in specific format .Ex- Single parts as individual STP files , and assemblies as individual STP files .
que_sgfyx6.png
 
I have to upload cat parts from local folder and get them converted into the required format if I use Utility option . I don't have the catparts (installation 3d models) saved locally . I load them from ENOVIA and have to save each locally in the required STP , 3dxml format .If it can be done by utility option please tell me how .
Thanks in advance
 
Sorry for that .Can you help me in customizing the above code in order to save parts in required format !.
 
That code will not work in this case, you have to think a little bit out of the box.

You can do a custom query in ENOVIA and load from there in your CATIA session your desired parts. Then, with a macro, you can export and close one by one your files (export on a local folder).

This can be done also in another way but I suppose you are not an admin in ENOVIA (and again, you need also license to do this).

By the way, did you tried to do this manually?

Regards
Fernando

- Romania
- EU
 
I tried .The main problem is single parts inside the assembly get saved ( instead of assembly as a product itself) , so it creates a problem .If somehow I can save single parts as CATParts and assemblies as CATProducts in one shot it will make work easier.
 
hello ,
still waiting for the macro .
any help will be great !.
thanks in advance :)
 
really? and we are still waiting to see your progress in trying to solve it on your own :)

regards,
LWolf
 
Did you asked a specialized company for a quotation to do this ?
ans- No , this is my own study in minimizing the efforts required to perform the task (saving files in STP , 3dxml format)

Did you asked your DS VAR for a solution for your problem ?
ans - No , because the above code which I customized seems almost complete . Because I have already written a code to load CATParts , CATProducts from local and save them in STP , 3dxml format . Here in this case as I load the installation (CATProduct) which child products when I try to save locally only single parts get saved ( all the single parts , including the ones in child CTProducts).
So when I try to convert them into stp or 3dxml by importing them from local files only single part SP or 3dxml gets generated and child CATProducts are not saved .This part is bugging me - how to save installation locally as it is ( as the given tree structure ).

Did you tried to do some code ? What you noticed ?
Yea , the above mentioned at the start of the thread is what I tried which throws an error. After that I did not try anything else yet.
 
If I understood well, you cannot save CATProduct from ENOVIA to local folders. For this, you need to use SendTo Directory.

Another idea is to get names and position of the CATParts/CATProducts from your CATproduct in ENOVIA and rebuild the CATProduct locally using data extracted before.

Another idea is to make an AllCATPart from CATProduct, then break it in a local CATProduct (you can use another macro for this) and replace those new created parts with yours (if is necessary) to have the CATProduct from ENOVIA.

After this, using the right license shouldn't be a problem to convert to what ever you want. But if you convert to stp or 3dxml I suppose you don't even need to do the replacement.

Sometimes you cannot achieve the final goal in a single step...

By the way, management should think about how much time take to a user/developer to do something instead of buying a solution already done (of course, you need to do the math in terms of time, money, a.s.o. and see what is more convenient).

Regards
Fernando

- Romania
- EU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor