Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding an image

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
xenin
671 Views, 6 Replies

Adding an image

hi,
Please help me in inserting or adding an image to the drawing file.. i ve the reference point and the bmp file path.. but the error "Run-time error '-2147467259(80004005) Method 'Add' of object '_IRxSketchImages' failed" is flashed.
thanks in advance..
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: xenin

There are a couple of limitations when inserting sketch images in drawings:

1. Images can only be inserted into sketches of drawing resources
(titleblocks, borders and sketched symbols). Note that the equivalent UI
command is disabled in sheet and view sketches. Same restrictions apply to
the API.
2. The drawing sketch needs to be in edit mode.

Here is a sample that inserts an image into the titleblock of the active
sheet.

Sub InsertImage()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oTitleBlockDef As TitleBlockDefinition
Set oTitleBlockDef = oDoc.ActiveSheet.TitleBlock.Definition

Dim oSketch As DrawingSketch
Call oTitleBlockDef.Edit(oSketch)

Dim oPoint As Point2d
Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(10, 30)

Dim oSketchImage As SketchImage
Set oSketchImage = oSketch.SketchImages.Add("C:\temp\block.bmp", oPoint)

oTitleBlockDef.ExitEdit
End Sub

Sanjay-
Message 3 of 7
kmiller
in reply to: xenin

I am wondering if you can help me.  This code below keeps returning an unhandled exception saying the parameter is incorrect at:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.SketchImages.Add(String FullFileName, Point2d Position, Boolean Link)
   at BarcodeTicket.frmBarcodeTicketMain.btnBarcode_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

--- BREAK ----

 

I have no idea what I have wrong here.  I am runing it on an inventor.dwg file.  It  get's to the point of editing the border sketch.  I just can't see why it's not working.  I have tried a number of different senarios.  

Here is my code:

 

Dim oActiveDoc As Inventor.DrawingDocument

oActiveDoc = InvApplication.ActiveDocument

       

Dim oCSTicBorderDefs As Inventor.BorderDefinitions

oCSTicBorderDefs = oActiveDoc.BorderDefinitions

       

Dim oCSTicBorderDef As Inventor.BorderDefinition

        oCSTicBorderDef = oCSTicBorderDefs.Item(

"StandardBorder")

        oCSTicBorderDef.Edit(oCSTicBorderDef.Sketch)

       

Dim oImagePlacementPoint As Inventor.Point2d

        oImagePlacementPoint = InvApplication.TransientGeometry.CreatePoint2d(0.55, 1.55)

Dim strImagePath AsString

        strImagePath ="C:\CAD_Temp\Barcodes\11040857.png"

       

Dim oSketchimage AsSketchImage

        oSketchimage = oCSTicBorderDef.Sketch.SketchImages.Add(strImagePath, oImagePlacementPoint, False)

        oCSTicBorderDef.ExitEdit(True)

 

 

 

-------------------------------------------------------------------------------------------------

If this response answers your question please click "Accept as Solution".
Message 4 of 7
jdkriek
in reply to: kmiller

I only managed to replicate the error if the image path was read-only or didn't have rights to the image itself.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 7
kmiller
in reply to: xenin

"Technically" no, I changed it for purposes of posting.  But even taking it and switching it to that name doesn't work on my end.  I have tried a couple of different configs with that.  When I run the code it doesn't even get to inserting the image in the border.  It get's to the point where it edits the border and is in sketchmode so it has to be finding it.  I am thinking it's bombing out at adding the sketch image, but I cannot figure out why that is.  I am trying to add a .png file, I can't imagine that would be the issue.  I thought maybe my Point2D position was wrong because I entered in decimal inches.  I assumed that would work even if I found out it was in the wrong spot.  I tried putting in some whole numbers for the value but it didn't work either. 

 

Unless for some reason I am taking the wrong approach.  I am using VB express so the debugging isn't as friendly but I can usually get it figured out.   

-------------------------------------------------------------------------------------------------

If this response answers your question please click "Accept as Solution".
Message 6 of 7
kmiller
in reply to: xenin

I do have all the rights, file is not set to read-only.  So there has to be something else.  I am stumped!

-------------------------------------------------------------------------------------------------

If this response answers your question please click "Accept as Solution".
Message 7 of 7
kmiller
in reply to: kmiller

I have my issue fixed per help from ADN.  You cannot use a png file to pass per code for an image type.  I also did not make a copy of a new sketch I was trying to edit the one I had.  After that, it seemed to work.  

-------------------------------------------------------------------------------------------------

If this response answers your question please click "Accept as Solution".

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report