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 CATIA from cat.drawing to TIFF

Status
Not open for further replies.

pnavy

Mechanical
Feb 5, 2014
19
Hello,

since I wanted to reply on all ready open thread but i could not I decided to open a new thread, for that if I am wrong I am sorry!

I have started to get acquainted with some basic macro programs for catia and I found macro to convert from drawing to pdf.
The problem is that I get compile error (byref argument type mismatch) message every time, seems that is something wrong with IESIRE and INTRARE statement.

I use catia v5r20

so below is quote from user ferdo from 20 Mar 06 18:43 source
---------------------------------------------------------------------------------------------------------
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
---------------------------------------------------------------------------------------------------------
 
Replies continue below

Recommended for you

VBA,

yes, it is for .pdf, but if i read correctly you can change .pdf to .tif?
 
OK , but I am sorry to say that I still get error.

source: CATIAdocuments
Description: The merhod open failed
Line: 18
column: 4

many thanks:)
 
ok, It works fine i did not finish the folder adress with \ like:C:\Users\....\2D\cat
thanks!
 
Hello,

It is me again, so I use the macro and it works! But I am wondering if it is possile to edit the code so that the extension .catdrawing would not be inserted in .tiff file naming:
Example:
Name of CAD drawing with extension: drawing_1.CATdrawing
name of converted file with extension: drawing_1.CATdrawing.tiff

many thanks!
 
hii pnavy,
for this you can use Left command to remove extra character from the name string

check below code

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
dim a as string
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

INTRARE = folderinput & f1.name
Set PartDocument1 = CATIA.Documents.Open(INTRARE)
a=Left(f1.name , Len(f1.name ) - 11)

IESIRE = folderoutput & a & ".pdf"
PartDocument1.ExportData IESIRE, "pdf"


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

CATIA.ActiveDocument.Close

Next

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor