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
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
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,