- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to make a triangular extrude + cut on an object with the inventor api. I use these codes for this, but "Profiles.AddForSolid();" I'm getting the "parameter incorrect" error in the function. How can I fix this error or is there a different extrude operation for the triangle?
error :
PlanarSketch osketch = compDef.Sketches.Add(compDef.WorkPlanes[3]);
TransientGeometry tg = _application.TransientGeometry;
Inventor.SketchPoints points = osketch.SketchPoints;
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(tg.CreatePoint2d(0, 40), tg.CreatePoint2d(40, 40));
line3 = lines.AddByTwoPoints(line2.EndSketchPoint, line1.StartSketchPoint);
Profile oProfile = osketch.Profiles.AddForSolid();
ExtrudeDefinition oExtrudeDef = compDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kCutOperation);
oExtrudeDef.SetDistanceExtent(4, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection);
ExtrudeFeature oExtrude = compDef.Features.ExtrudeFeatures.Add(oExtrudeDef);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @hayattangercekler2. The most common problem I see when folks are drawing geometry entirely by code, that they then intend to extrude, is 'how' the geometry is drawn. In order for the Coincident constraints to be inferred at the end points of the profile's sections, you need to either use end points or start points of existing geometry when drawing the next connecting piece of geometry, not just matching numerical locations. Otherwise, you would need to go back and add those coincident constraints, in order for it to be recognized as a 'closed' profile. Your 'line3' was done correctly, but not 'line2'.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@WCrihfield wrote:
Hi @hayattangercekler2. The most common problem I see when folks are drawing geometry entirely by code, that they then intend to extrude, is 'how' the geometry is drawn. In order for the Coincident constraints to be inferred at the end points of the profile's sections, you need to either use end points or start points of existing geometry when drawing the next connecting piece of geometry, not just matching numerical locations. Otherwise, you would need to go back and add those coincident constraints, in order for it to be recognized as a 'closed' profile. Your 'line3' was done correctly, but not 'line2'.
@hayattangercekler2 ... I just looked at what @WCrihfield was saying about line 2 and realized that I should mention that I changed the way that line was done as well, but I didn't see that resolve the error. Maybe it was just a bad test on my end though?
I just checked again and it fails with the sketch edit lines if line 2 is done per your original example. You can test that on your end to see if the sketch edit lines are indeed needed, or if I fooled myself with those when I looked at the previously.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report