Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

How to insert logo in multiple Catia drawings opened in session using macro?

Status
Not open for further replies.

Rangraop

Automotive
Mar 19, 2014
21
0
0
US
Hello Guys,
Recently I posted regarding inserting a pdf file in catia drawing.. and still trying to do so.
Now I want to insert logos in multiple catia drawings already opened in session. Can anybody help me in correcting this code (highlighted)??

********************************************
Public Sub CATMain()

on error resume next
Set oDocument = CATIA.ActiveDocument
If Err.Number <> 0 Then
Set oDocument = CATIA.Documents.Add("Drawing")
Err.Clear
End If
On Error GoTo 0

Set oSheets = oDocument.Sheets
Set oSheet = oSheets.ActiveSheet
Set oView = oSheet.Views.ActiveView
Set oPictures = oView.Pictures
Set oWindowsopen = CATIA.Windows

[highlight #F57900]counter = 0

For i=1 to oWindowsopen.count

CATIA.Windows.item(i).Activate

InsertPicture "c:\temp\Logo.jpg", 150, 0, RATIOHEIGHT, 100,25

counter = counter+1

Next[/highlight]

End Sub

Sub InsertPicture (strPath , dblAnchorX, dblAnchorY, prRatio, dblWidth, dblHeight)
Dim objPicture

Set objPicture = oPictures.Add(strPath, dblAnchorX, dblAnchorY)
FormatPicture objPicture, prRatio,-1 ,-1 , dblWidth, dblHeight

Set objPicture = Nothing
End Sub

Public Sub FormatPicture(objPicture , prRatio , dblAnchorX, dblAnchorY, dblWidth , dblHeight )
Dim dblScalar

If dblAnchorX >= 0 Then objPicture.X = dblAnchorX
If dblAnchorY >= 0 Then objPicture.Y = dblAnchorY

If prRatio = RATIOWIDTH Then
'Picture scaled by width with fixed ratio
If dblWidth > 0 Then
dblScalar = objPicture.Width / dblWidth
objPicture.Height = objPicture.Height / dblScalar
objPicture.Width = dblWidth
End If
ElseIf prRatio = RATIOHEIGHT Then
'Picture scaled by Height with fixed ratio
If dblHeight > 0 Then
dblScalar = objPicture.Height / dblHeight
objPicture.Width = objPicture.Width / dblScalar
objPicture.Height = dblHeight
End If
Else
'Picture scaled by width & height
If dblWidth > 0 Then objPicture.Width = dblWidth
If dblHeight > 0 Then objPicture.Height = dblHeight
End If

End Sub
**************************************************************
 
Replies continue below

Recommended for you

the CATIA.ActiveDocument and sheets, views... should be redefine in your InsertPicture

Eric N.
indocti discant et ament meminisse periti
 
Thanks for your reply eric, actually I have to switch between multiple catia dwgs opened in session and insert logos. I think you understood what my query is.
Thank you.
Rangrao
 
Status
Not open for further replies.
Back
Top