Reply
Solved! Go to solution

SE API C# extrudedCutout problem

[ Edited ]

Hello

 

I made sketch in C#  and close it, all its arc + lines are connected from end points, profile is closed.

But using command:

extrudedCutout = extrudedCutouts.AddThroughAll(profile2, SolidEdgePart.FeaturePropertyConstants.igRight, SolidEdgePart.FeaturePropertyConstants.igRight);

 

It Gives: internal error: Unable to compute topology information for the sketched profile.

 

Same Profile is selected initially in cutout.

 

But if I reshow this same sketch in sketch step of failed cut operation it work perfectly.

 

Any one found same bug and solved it?

 

14 REPLIES

Re: SE API C# extrudedCutout problem

Hello jussi:

 

Please see if this post is related your query:

https://community.plm.automation.siemens.com/t5/Solid-Edge-Developer-Forum/ExtrudedCutout-using-mult...

 

~Tushar

 

Re: SE API C# extrudedCutout problem

 

Starts with arc lines trims deleting lines to form closed profile.

This last part, it connects lose ends and closes profile.

 

// Define Relations among the Line objects to make the Profile closed
relations2d = (SolidEdgeFrameworkSupport.Relations2d)
profile2.Relations2d;

relation2d = relations2d.AddKeypoint(lines2d.Item(1), (int)KeypointIndexConstants.igLineStart, lines2d.Item(3), (int)KeypointIndexConstants.igLineStart, true);
relation2d = relations2d.AddKeypoint(lines2d.Item(3), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(5), (int)KeypointIndexConstants.igLineStart, true);
relation2d = relations2d.AddKeypoint(lines2d.Item(5), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)KeypointIndexConstants.igLineEnd, true);
relation2d = relations2d.AddKeypoint(lines2d.Item(4), (int)KeypointIndexConstants.igLineStart, lines2d.Item(2), (int)KeypointIndexConstants.igLineStart, true);


// Close the profile
profile2.End(SolidEdgePart.ProfileValidationType.igProfileClosed);
profile2.Visible = false;
profileList.Add(profile2);

models = part_Document.Models;
model = models.Item(1);

extrudedCutouts = model.ExtrudedCutouts;
extrudedCutout = extrudedCutouts.AddThroughAll(profile2, SolidEdgePart.FeaturePropertyConstants.igRight, SolidEdgePart.FeaturePropertyConstants.igRight);

Re: SE API C# extrudedCutout problem

I am not sure, if this is your first extrusion in the document.

If yes, you don't have yet a model, so your line models.Item(1) will fail.

To create a new model from an extruded protrusion, you should use the models.AddFiniteExtrudedProtrusion(..) call.

Re: SE API C# extrudedCutout problem

Hello

 

Part is defined earlyer, it has protrusions and revolved protrusions.

It allso has 3 cut outs made earlyer.

These other cutouts works well, only differense is that these earlyer 

cutout have not used trims or deleting lines.

Re: SE API C# extrudedCutout problem

Sorry, my fault. I was reading the post in diagonal and did not recognize that you were creating a cutout.

Can you please post your code which creates the profile?

I have seen that some operations may cause the profile to be disconnected, maybe the trim operation is one of those?

To be sure, you may simply reconnect all primitives again and toggle all unused (trimmed) primitives into construction primitives. If you have additional primitives in your profile, the cutout will fail.

Re: SE API C# extrudedCutout problem

Hello

 

I took comments out and renamed all.

 

static void CreateExtrudedCutout(SolidEdgePart.PartDocument part_Document, double val, double val2, double val3)
{
SolidEdgePart.RefPlanes refPlanes = null;
SolidEdgePart.RefPlane refPlane = null;
SolidEdgePart.Sketchs sketchs = null;
SolidEdgePart.Sketch sketch = null;
SolidEdgePart.Profiles profiles2 = null;
SolidEdgePart.Profile profile2 = null;
SolidEdgeFrameworkSupport.Lines2d lines2d = null;
SolidEdgeFrameworkSupport.Line2d line2d = null;
SolidEdgeFrameworkSupport.Circles2d circles2d = null;
SolidEdgeFrameworkSupport.Circle2d circle2d = null;
SolidEdgeFrameworkSupport.Arcs2d arcs2d = null;
SolidEdgeFrameworkSupport.Arc2d arc2d = null;
SolidEdgeFrameworkSupport.Relations2d relations2d = null;
SolidEdgeFrameworkSupport.Relation2d relation2d = null;
SolidEdgePart.Models models = null;
SolidEdgePart.Model model = null;
SolidEdgePart.ExtrudedCutouts extrudedCutouts = null;
SolidEdgePart.ExtrudedCutout extrudedCutout = null;
List<SolidEdgePart.Profile> profileList = new List<SolidEdgePart.Profile>();
double Val = 0.0;
double Y_Pos = 0, X_Pos = 0;
double Val2 = 0, dummy;

 

// Get refplane.
refPlanes = part_Document.RefPlanes;
refPlane = refPlanes.Item(2);

// Create 2nd sketch.
sketchs = part_Document.Sketches;
sketch = sketchs.Add();

// Create profile.
profiles2 = sketch.Profiles;
profile2 = profiles2.Add(refPlane);


// Get a reference to the lines2d collection
lines2d = profile2.Lines2d;
circles2d = profile2.Circles2d;
arcs2d = profile2.Arcs2d;

Val = (3.14159 / 2 * val)/1000;
Val2 = 2 * Math.Asin(Val / val2);
Y_Pos = (val2/2) * Math.Cos(Val2);
X_Pos = Val / 2;
arcs2d.AddByCenterStartEnd(0, 0, X_Pos, Y_Pos, -X_Pos, Y_Pos);
circle2d = circles2d.AddByCenterRadius(0, 0, ((val2/2)-((1.25*val)/1000)));
arcs2d.Item(1).GetStartPoint(out X_Pos, out Y_Pos);
lines2d.AddByPointAngleLength(X_Pos,Y_Pos,(Math.PI/180*(-val3)),((1.85*val)/1000));
arcs2d.Item(1).GetEndPoint(out X_Pos, out Y_Pos);
lines2d.AddByPointAngleLength(X_Pos, Y_Pos, (Math.PI / 180 * (180+val3)), ((1.85 * val) / 1000));

arcs2d.Item(1).Delete();
lines2d.Item(1).GetEndPoint(out X_Pos, out Y_Pos);
lines2d.Item(1).Trim(X_Pos, Y_Pos, circles2d.Item(1));
lines2d.Item(2).GetEndPoint(out X_Pos, out Y_Pos);
lines2d.Item(2).Trim(X_Pos, Y_Pos, circles2d.Item(1));

double x = 0;
double y = 0;
double z = 0;
SolidEdgeFramework.KeyPointType keypointType;
int handleType = 0;

circles2d.Item(1).GetKeyPoint(
Index: 2,
x: out x,
y: out y,
z: out z,
KeypointType: out keypointType,
HandleType: out handleType);

circles2d.Item(1).Trim(x, y, lines2d.Item(1), lines2d.Item(2));

lines2d.Item(1).GetStartPoint(out X_Pos, out Y_Pos);
lines2d.AddByPointAngleLength(X_Pos, Y_Pos, (Math.PI / 180 * (180-val3)), ((1.85 * val) / 1000));
lines2d.Item(2).GetStartPoint(out X_Pos, out Y_Pos);
lines2d.AddByPointAngleLength(X_Pos, Y_Pos, (Math.PI / 180 * ( val3)), ((1.85 * val) / 1000));

double X_Pos2 , Y_Pos2;
lines2d.Item(3).GetEndPoint(out X_Pos, out Y_Pos);
lines2d.Item(4).GetEndPoint(out X_Pos2, out Y_Pos2);
lines2d.AddBy2Points(X_Pos, Y_Pos, X_Pos2, Y_Pos2);

relations2d = (SolidEdgeFrameworkSupport.Relations2d)
profile2.Relations2d;

relation2d = relations2d.AddKeypoint(lines2d.Item(1), (int)KeypointIndexConstants.igLineStart, lines2d.Item(3), (int)KeypointIndexConstants.igLineStart, true);
relation2d = relations2d.AddKeypoint(lines2d.Item(3), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(5), (int)KeypointIndexConstants.igLineStart, true);
relation2d = relations2d.AddKeypoint(lines2d.Item(5), (int)KeypointIndexConstants.igLineEnd, lines2d.Item(4), (int)KeypointIndexConstants.igLineEnd, true);
relation2d = relations2d.AddKeypoint(lines2d.Item(4), (int)KeypointIndexConstants.igLineStart, lines2d.Item(2), (int)KeypointIndexConstants.igLineStart, true);

profile2.End(SolidEdgePart.ProfileValidationType.igProfileClosed);

profile2.Visible = false;
profileList.Add(profile2);

models = part_Document.Models;
model = models.Item(1);

extrudedCutouts = model.ExtrudedCutouts;
extrudedCutout = extrudedCutouts.AddThroughAll(profile2, SolidEdgePart.FeaturePropertyConstants.igRight, SolidEdgePart.FeaturePropertyConstants.igRight);

}

Re: SE API C# extrudedCutout problem

Do you also have some sample values for val, val2, and val3 to test with?

Re: SE API C# extrudedCutout problem

I haven't tested it, but I believe that the automatic connect which SE is doing when interactively trimming a line or circle is NOT done by the API, so you will have to connect your resulting Arc2d object with the lines through API.

Re: SE API C# extrudedCutout problem

Here is some sample code, which was working for me:

Spoiler
PartDocument part_Document = (PartDocument)pSEApp.ActiveDocument;
double innerR = 30;
double outerR = 40;
double angle = 60;

// Get refplane.
SolidEdgePart.RefPlane refPlane = part_Document.RefPlanes.Item(2);

// Create profile.
//SolidEdgePart.Profile profile = part_Document.Sketches.Add().Profiles.Add(refPlane);
SolidEdgePart.Profile profile = part_Document.ProfileSets.Add().Profiles.Add(refPlane);

double xpos = Math.Cos(Math.PI * (90 - angle / 2) / 180) * outerR /1000;
double ypos = Math.Sin(Math.PI * (90 + angle / 2) / 180) * outerR / 1000;
profile.Circles2d.AddByCenterRadius(0, 0, innerR/1000);
profile.Arcs2d.AddByCenterStartEnd(0, 0, xpos, ypos, -xpos, ypos);
profile.Lines2d.AddByPointAngleLength(xpos, ypos, Math.PI * (-angle / 2 - 90) / 180, (outerR - innerR) * 1.1 / 1000);
profile.Lines2d.AddByPointAngleLength(-xpos, ypos, Math.PI * (angle / 2 - 90) / 180, (outerR - innerR) * 1.1 / 1000);

object optArg = Type.Missing;
profile.Lines2d.Item(1).Trim(0, 0, profile.Circles2d.Item(1), optArg);
profile.Lines2d.Item(2).Trim(0, 0, profile.Circles2d.Item(1), optArg);
profile.Circles2d.Item(1).Trim(0, innerR, profile.Lines2d.Item(1), profile.Lines2d.Item(2));

// Connect the lines and the outer arc (the trimmed circle is auto-connected to the lines!)
SolidEdgeFrameworkSupport.Relations2d relations = (SolidEdgeFrameworkSupport.Relations2d) profile.Relations2d;
relations.AddKeypoint(profile.Lines2d.Item(1), (int)KeypointIndexConstants.igLineStart, profile.Arcs2d.Item(1), (int)KeypointIndexConstants.igArcStart, true);
relations.AddKeypoint(profile.Arcs2d.Item(1), (int)KeypointIndexConstants.igArcEnd, profile.Lines2d.Item(2), (int)KeypointIndexConstants.igLineStart, true);

profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed);
profile.Visible = false;

part_Document.Models.Item(1).ExtrudedCutouts.AddThroughAll(profile, SolidEdgePart.FeaturePropertyConstants.igLeft, SolidEdgePart.FeaturePropertyConstants.igBoth);