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: 

Repeat projection of axis causes System.Runtime.Interopservices.COMException

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
rogmitch
533 Views, 2 Replies

Repeat projection of axis causes System.Runtime.Interopservices.COMException

I have a VBA macro which projects axes combinations into a part sketch with a single click.  I could project, for example, the XY axes immediately followed by the XZ axes without problem.

 

On converting to an addin (VB.NET) it fails at :

 

oProjectionEntity = oSketch.AddByProjectingEntity(oPartCompDef.WorkAxes.Item(1)) 'X axis       if a projected X axis already exists.  

 

If I delete the existing projected axis the code will then run correctly.

 

The error is  System.Runtime.Interopservices.COMException (0x80004005):Unspecified error....etc.  See attachment for full error text.

 

Does anyone have any idea why this should fail or how I might test for the existence of a projected axis prior to trying to project onto the same axis.

 

Any help appreciated.

 

Roger Mitchell

 

IV 2014 Professional 64 bit SP1 Update2, VS Studio Express 2013

2 REPLIES 2
Message 2 of 3
adam.nagy
in reply to: rogmitch

Hi Roger,

 

Your description was misleading. I was thinking why .NET would behave differently from VBA, but in fact they are the same.

If you already have X axis projected onto the sketch then VBA will also throw an error when you try to create another projection of the same axis. 

 

I think you could just simply handle the error - in case of .NET it would be a Try/Catch. 

If you also need to get back the existing projected sketch entity then you would need to iterate through the sketch entities and check which one is referencing (SketchEntity.ReferencedEntity) the axis you are trying to project.

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 3
rogmitch
in reply to: adam.nagy

My apologies - I forgot about the On Error Resume Next in my VBA code. I will trap the error in the addin as you suggest.
Thank you for the response.

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

Post to forums  

Autodesk Design & Make Report