×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro to convert files (TIF or PDF)
2

Macro to convert files (TIF or PDF)

Macro to convert files (TIF or PDF)

(OP)
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?

RE: Macro to convert files (TIF or PDF)

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:

http://2htts.com/CATBlog/index.php?itemid=9#more


---
Professional and reliable CAD design engineering services - Specializing in Catia V4, Catia V5, and CAD Translation.  Catia V5 resources - CATBlog

RE: Macro to convert files (TIF or PDF)

Runz (Aerospace)
(OP)
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,

RE: Macro to convert files (TIF or PDF)

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

RE: Macro to convert files (TIF or PDF)

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

RE: Macro to convert files (TIF or PDF)

(OP)
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.

RE: Macro to convert files (TIF or PDF)

(OP)
Is it that this macro will not work with non CATDrawing files, such as the .cdd (Cadam) files that I am trying to convert?

RE: Macro to convert files (TIF or PDF)


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

RE: Macro to convert files (TIF or PDF)

PeterGuy (Automotive)
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

RE: Macro to convert files (TIF or PDF)

(OP)
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,

RE: Macro to convert files (TIF or PDF)

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

RE: Macro to convert files (TIF or PDF)

(OP)
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!

RE: Macro to convert files (TIF or PDF)

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

RE: Macro to convert files (TIF or PDF)

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

I'm running v5R14 sp4

thanks,

RE: Macro to convert files (TIF or PDF)

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

Regards,
Derek

RE: Macro to convert files (TIF or PDF)

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

RE: Macro to convert files (TIF or PDF)

Thanks Fernando


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources