There is no API to constrain inserted image 😞 but it is not difficult to simplify logo insertion with iLogic .
The following external iLogic rule embeds specified logo (bmp-file) into the title block definition. You may specify both position and image size.
Coordinates should be defined
- in the base length units (cm) and
- in the sketch coordinate system.
Look at this video to see how the rule works:
https://chronicle.autodesk.com/Main/Details/73f9f5e2-014b-4928-931f-79f6a7c258d8
'This rule embeds Logo image into title block definition
'Image position and size are specified.
Sub Main
'check if the active document is drawing document
If Not TypeOf(ThisDoc.Document) Is DrawingDocument Then
MessageBox.Show("Run this rule when Drawings document is active", _
"Logo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, _
MessageBoxDefaultButton.Button1)
Exit Sub
End If
'1) define full path to the Logo image
Dim LogoFilename As String = "c:\Temp\RulerCorp.bmp"
'2) specify Logo image size - 0.62in x 0.62in
' Use cantimeters! - Inventor internal units
Dim LogoHeight As Double = 0.62*2.54 'in cm
Dim LogoWidth As Double = LogoHeight
'3) specify insertion point coordinates X = 7.75in, Y = 7.45in
' Use cantimeters! - Inventor internal units
' Sketch coordinate system is used.
Dim InsPointX As Double = 7.75*2.54 'in cm
Dim InsPointY As Double = 7.45*2.54 'in cm
'4) the final step - insert Logo
InsertImage(LogoFilename,InsPointX,InsPointY, LogoWidth, LogoHeight)
Beep 'could be removed
End Sub
Sub InsertImage( _
LogoFilename As String, _
InsPointX As Double, _
InsPointY As Double, _
LogoWidth As Double, _
LogoHeight As Double)
Dim oDoc As DrawingDocument = ThisDoc.Document
'set target point in the title block sketch coordinates (in cm)
Dim oPoint As Point2d = ThisApplication.TransientGeometry _
.CreatePoint2d(InsPointX, InsPointY)
Dim oTitleBlockDef As TitleBlockDefinition _
= oDoc.ActiveSheet.TitleBlock.Definition
Dim oSketch As DrawingSketch
Call oTitleBlockDef.Edit(oSketch)
Dim oSketchImage As SketchImage
'add embedded image
oSketchImage = oSketch.SketchImages.Add(LogoFilename, oPoint, False)
'set image size in cm
oSketchImage.Height = LogoHeight
oSketchImage.Width = LogoWidth
oTitleBlockDef.ExitEdit
End Sub 'InsertImage
Cheers,
Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network