Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
mirkomaga
316 Views, 2 Replies

Hole Feature and shared Sketch. VB and C# disagree

Hello,
I trying to get Sketch Definition from Hole Feature.

Considering that it is the same document:

 

VB: 

mirkomaga_0-1650523286064.png

 

 

Addin c#:

mirkomaga_1-1650523390172.png

 

 

As you can well see: in the second image the sketch throw me an exception that is not there in the first one.

 

This is Model, anyone have the same problem?

mirkomaga_2-1650523529902.png

 

Zach.Stauffer
in reply to: mirkomaga

Can you share VB and C# code?

jatindevaiya08
in reply to: mirkomaga

@mirkomaga 

I have created C# code for the same and it's working fine for me. See attached images.

Test_4.png

SketchName_1.png


Here is the C# code. It's console Application code. And note that Inventor application as well as Part is open when you test it.

 

 

Inventor.Application inventorApplication = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");

PartDocument partDocument = (PartDocument)inventorApplication.ActiveDocument;
PartComponentDefinition partComponentDefinition =partDocument.ComponentDefinition;

foreach (PartFeature partfeature in partComponentDefinition.Features)
{
  if (partfeature.Type == ObjectTypeEnum.kHoleFeatureObject)
  {
    HoleFeature holeFeature = (HoleFeature)partfeature;
    Console.WriteLine(holeFeature.Sketch.Name);
   }
}

 

 


Regards,
Jatin Devaiya

Accept it as solution.

Regards,
Jatin Devaiya

If a response answers your question, please use ACCEPT SOLUTION to assist other users later.


Also be generous with Likes! Thank you and enjoy!