×
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

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

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

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

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

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


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
**************************************************************

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

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

Eric N.
indocti discant et ament meminisse periti

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

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

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