Solved! Go to Solution.
Solved by kmiller. Go to Solution.
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)
"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.
I do have all the rights, file is not set to read-only. So there has to be something else. I am stumped!
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.