Rangraop
Automotive
- Mar 19, 2014
- 21
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
**************************************************************
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
**************************************************************