C# Inventor api HoleFeature Problem

C# Inventor api HoleFeature Problem

Anonymous
Not applicable
289 Views
1 Reply
Message 1 of 2

C# Inventor api HoleFeature Problem

Anonymous
Not applicable

Hi guys,

Here is my c#code

private void button2_Click(object sender, EventArgs e)
{
Inventor.Application application = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
PartDocument prt = (PartDocument)application.Documents.Add(DocumentTypeEnum.kPartDocumentObject, application.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject), true);
prt.UnitsOfMeasure.LengthUnits = UnitsTypeEnum.kMillimeterLengthUnits;
PartComponentDefinition cdef = prt.ComponentDefinition;
PlanarSketch sktch = cdef.Sketches.Add(cdef.WorkPlanes["XY Plane"], true);
TransientGeometry transgeo = application.TransientGeometry;
SketchLine pipe = sktch.SketchLines.AddByTwoPoints(transgeo.CreatePoint2d(0, 0), transgeo.CreatePoint2d(0, 10));
pipe.Centerline = true;

SketchEntitiesEnumerator rectanglelines = sktch.SketchLines.AddAsTwoPointRectangle(transgeo.CreatePoint2d(2, 0), transgeo.CreatePoint2d(5, 3));

Profile profile2 = sktch.Profiles.AddForSolid();
RevolveFeature revolve = cdef.Features.RevolveFeatures.AddFull(profile2, pipe, PartFeatureOperationEnum.kJoinOperation);
SurfaceBodies bodies = revolve.SurfaceBodies;
WorkPlane wp = cdef.WorkPlanes.AddByPlaneAndOffset(bodies[1].Faces[2], 0);
PlanarSketch sktch2 = cdef.Sketches.Add(wp, true);
SketchPoint point = sktch2.SketchPoints.Add(transgeo.CreatePoint2d(0, 2.5));
sktch2.Shared = true;
wp.Shared = true;

HoleFeature hf = cdef.Features.HoleFeatures.AddDrilledByThroughAllExtent(point,0.1, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);

}

My codes working well until last line.

i always get "HRESULT: 0x80004005 " ERROR

i think i'm doing exactly same in the İnventors' Hole Exapmles;

Thank You for your help.

0 Likes
290 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Duplicate Topic. 

please delete this one. I'm so sorry

0 Likes