Hi, I'm struggeling to run a code that works well for parts, but fails when running on an in-place edited part.
Basically it fails when trying to add a sketch with
PartComponentDefinition.Sketches.Add(selectedPlanarFace, false)
The workflow would be that the user starts in-place edit of a part component. Then the Inventor Addin is started and asks the user to pick a face. Based on that selection, it creates a planar sketch on this face.
When run directly for the part component everything works well.
When run in-place, I'm getting the ActiveEditDocument. Casting as PartDocument and reading existing sketches from
PartComponentDefinition works well in Debugging. As soon as I try adding a new PlanarSketch with the selected planar face, it will crash with "Wrong parameter".
I suspect that the selected face is somehow in occurence context, so it cannot be used to create a new sketch.
Any ideas, someone?
Solved! Go to Solution.
Solved by Michael.Navara. Go to Solution.
When you pick the face in assembly context, it is FaceProxy object (not Face object). In this case you can use
Dim oFace as Face = selectedPlanarFace.NativeObject
Yesss. I was just going to post that is was a proxy issue. Sometimes it helps writing down you issue. Thank you anyways.
Can't find what you're looking for? Ask the community or share your knowledge.