Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Macro to convert files (TIF or PDF) 2

Status
Not open for further replies.

Runz

Aerospace
Oct 3, 2005
216
We have legacy data of old Cadam (ccd) files that we would like to convert to TIF or PDF. Does anyone know of a macro or program available to mass convert these files?
 
Replies continue below

Recommended for you

Do you have the ability to open the files directly into Catia?

Since you mentioned macro, I'm assuming that you meant V5. If that's the case, check this out:



---
Professional and reliable CAD design engineering services - Specializing in Catia V4, Catia V5, and CAD Translation. Catia V5 resources - CATBlog.
 
Yes the files can be opened directly into Catia drafting. However the macro does not work. I am not very familiar with VB and the following error pops up:

Source: Microsoft VBScript error
Description: Expected end of statement
Statement: Dim specsAndGeomWindow1 As SpecsAndGeomWindow
Line: 11
Column:24

See the language reference guide or the V5 Automation APIs documentation.


Any suggestions on the error?

Thanks,
 
Hi,

That macro was made for r12, running under Windows. Please try this old one (modified in a big hurry).
--------------------------------------
Language="VBSCRIPT"

Sub CATMain()

folderinput = InputBox ("Put your files here","Input","C:\temp\",2000,4000)
folderoutput = InputBox ("Take your files from here","Output","C:\tempout\",2000,4000)

Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderinput)
Set fc = f.Files

For Each f1 in fc

Dim PartDocument1 As Document
Set documents1 = CATIA.Documents
Dim document1 As Document

INTRARE = folderinput & f1.name
Set PartDocument1 = CATIA.Documents.Open(INTRARE)

IESIRE = folderoutput & f1.name & ".pdf"
PartDocument1.ExportData IESIRE, "pdf"


s = s & f1.name
s = s & vbCrLf

CATIA.ActiveDocument.Close

Next

End Sub

----------------------------------------


Regards
Fernando
 
Hi again,

I forgot to mention that changing pdf extension with something else, its also possible to export stp, igs a.s.o.,depending on what you have in the input folder...


Regards
Fernando
 
Still having problems.

Source: Microsoft VBScript compilation error
Description: Expected end of statement
Statement: Dim PartDocument1 As Document
Line: 15
Column: 22

See the language reference guide or the V5 Automation APIs documentation.
 
Is it that this macro will not work with non CATDrawing files, such as the .cdd (Cadam) files that I am trying to convert?
 

It should work fine. It's calling the active document - not a particular file type.


---
Professional and reliable CAD design engineering services - Specializing in Catia V4, Catia V5, and CAD Translation. Catia V5 resources - CATBlog.
 
as we are talking about vbscript where everything is a variant of some type, try commenting out the variable typing

e.g.

Dim PartDocument1 'As Document

leaving the type in will work in catscript, vb, vba but not catvbs
 
I've cut and pasted the VB script as it is shown, but I get the error as noted. I am correct in that this macro runs outside of Catia and converts all files in the "c:\Temp\" Folder to PDF?

PeterGuy: I'm not sure I follow? Like I mentioned, I am not very familiar with VB. Could you please explain.

Thanks,
 
Runz - I picked this piece of info up from another forum (Nev Johnson). The difference between VBA and a CATScript.

Change

Dim oDocument As Document --VBA

to

Dim oDocument 'As Document --CATScript

ie find and replace all As with 'As

Regards
Derek
 
Thanks Derek. That seems to have fixed that problem and the macro starts to run, but then fails when it gets to line 23 (PartDocument1.ExportData IESIRE, "pdf")

Any more suggestions?

Here is the actual error message:

Source: CATIADocument
Description: The method ExportData failed
Line: 23
Column: 4

Thanks for all the help thus far!
 
Runz - I have modified this script and ran it on my machine.
Create 2 directories under C
tempdrawing temppdf

---------------------------------------------------------
Language="VBSCRIPT"

Sub CATMain()

folderinput = InputBox ("Take your files from here","Input","C:\tempdrawing\",2000,4000)
folderoutput = InputBox ("Put your files here","Output","C:\temppdf\",2000,4000)


Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderinput)
Set fc = f.Files

For Each f1 in fc

Dim PartDocument1 'As Document
Set documents1 = CATIA.Documents
Dim document1 'As Document

INTRARE = folderinput & f1.name
Set PartDocument1 = CATIA.Documents.Open(INTRARE)

IESIRE = folderoutput & f1.name & ".pdf"
PartDocument1.ExportData IESIRE, "pdf"


s = s & f1.name
s = s & vbCrLf

CATIA.ActiveDocument.Close

Next

End Sub
------------------------------------------------------

I am running R16 SP3

Regards,
Derek
 
Still failing at the following line
(PartDocument1.ExportData IESIRE, "pdf")

I'm running v5R14 sp4

thanks,
 
Runs in 15 SP5, not like that helps you out. Sorry, I don't have 14 installed anywhere.

Regards,
Derek
 
Hi there,

Sorry for my very,very,late intervention but I didn't have enough time to surf the net and give you some help.

First I want to thanks to Derek for trying to help (one star from me for this).

I've tested also his CATScript and its working without errors under r14, Windows XP. Also my script its working in same conditions.

I don't know what's happening on your computer Runz. Maybe you have some problems with your CATScript interpretor. I will try also to run the script under UNIX to see if I get some errors.

Regards
Fernando
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor