11-11-2022
07:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-11-2022
07:21 AM
I'm not entirely sure why that was not working, but adding a line to edit the sketch and then exit the sketch before and after the AddForSolid line seems to resolve the issue.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
{
PartDocument oDoc = ThisDoc.Document;
ComponentDefinition compDef;
compDef = oDoc.ComponentDefinition;
var _application = ThisApplication;
PlanarSketch osketch = compDef.Sketches.Add(compDef.WorkPlanes(3));
TransientGeometry tg = _application.TransientGeometry;
Inventor.SketchLines lines = osketch.SketchLines;
Inventor.SketchLine line1;
Inventor.SketchLine line2;
Inventor.SketchLine line3;
line1 = lines.AddByTwoPoints(tg.CreatePoint2d(0, 0), tg.CreatePoint2d(0, 40));
line2 = lines.AddByTwoPoints(line1.EndSketchPoint, tg.CreatePoint2d(40, 40));
line3 = lines.AddByTwoPoints(line2.EndSketchPoint, line1.StartSketchPoint);
osketch.Edit();
Profile oProfile = osketch.Profiles.AddForSolid;
osketch.ExitEdit();
ExtrudeDefinition oExtrudeDef = compDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation);
oExtrudeDef.SetDistanceExtent(4, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);
ExtrudeFeature oExtrude = compDef.Features.ExtrudeFeatures.Add(oExtrudeDef);
}
Dim oDoc As PartDocument = ThisDoc.Document Dim compDef As ComponentDefinition compDef = oDoc.ComponentDefinition Dim _application = ThisApplication Dim osketch As PlanarSketch = compDef.Sketches.Add(compDef.WorkPlanes(3)) Dim tg As TransientGeometry = _application.TransientGeometry Dim lines As Inventor.SketchLines = osketch.SketchLines Dim line1 As Inventor.SketchLine Dim line2 As Inventor.SketchLine Dim line3 As Inventor.SketchLine line1 = lines.AddByTwoPoints(tg.CreatePoint2d(0, 0), tg.CreatePoint2d(0, 40)) line2 = lines.AddByTwoPoints(line1.EndSketchPoint, tg.CreatePoint2d(40, 40)) line3 = lines.AddByTwoPoints(line2.EndSketchPoint, line1.StartSketchPoint) osketch.Edit Dim oProfile As Profile = osketch.Profiles.AddForSolid osketch.ExitEdit Dim oExtrudeDef As ExtrudeDefinition = compDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation) oExtrudeDef.SetDistanceExtent(4, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection) Dim oExtrude As ExtrudeFeature = compDef.Features.ExtrudeFeatures.Add(oExtrudeDef)