Cancel
Showing results for 
Search instead for 
Did you mean: 

Hollow Protrusion

Pioneer
Pioneer

Can someone please point me in the right direction with hollow protrusions in C#.

 

I've found numerous posts in VB that uses the nested profile constant, but I cannot get it to work for me in C#. I'm trying to do a circular tube (or pipe). Here's what I have, but it doesn't work...

 

                refPlanes = partDocument.RefPlanes;
                frontalPlane = refPlanes.Item(3);
                sketchs = partDocument.Sketches;
                sketch = sketchs.Add();
                profiles = sketch.Profiles;
                profile = profiles.Add(frontalPlane);
                circles2d = profile.Circles2d;

                application.DoIdle();

                circles2d.AddByCenterRadius(0, 0, 3 * kFactor);
                circles2d.AddByCenterRadius(0, 0, 2 * kFactor);

                profile.End(SolidEdgePart.ProfileValidationType.igProfileAllowNested);

                //MatTable mtable = application.GetMaterialTable();
                //mtable.ApplyMaterial(partDocument, "Steel");

                object[] nestedProfile = new object[] {profile};

                partDocument.Models.AddFiniteExtrudedProtrusion
                    (
                        NumberOfProfiles: 1,
                        ProfileArray: nestedProfile,
                        ProfilePlaneSide: SolidEdgePart.FeaturePropertyConstants.igLeft,
                        ExtrusionDistance: length
                    );
4 REPLIES 4

Re: Hollow Protrusion

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

@Z06Dre, please have a look at my earlier post in another discussion.

This should help you with your problem.

Re: Hollow Protrusion

Pioneer
Pioneer

@Z06Dre this code is usful for  pipe creation

 

~VPJ

Pdoc = (PartDocument)docs.Add("SolidEdge.PartDocument"); 

                RefPlane topPln = Pdoc.RefPlanes.Item(1);
                RefPlane rightPln = Pdoc.RefPlanes.Item(2);
                RefPlane frontPln = Pdoc.RefPlanes.Item(3);

                Profiles profs = Pdoc.ProfileSets.Add().Profiles;
                Profile prof = profs.Add(rightPln); // Plane selection
                Relations2d rels = (Relations2d)prof.Relations2d;
                Dimensions dim = (Dimensions)prof.Dimensions;

                //-----------------------------------------------------------------------------------
                //          Create Pipe
                //-----------------------------------------------------------------------------------   

                double pipeOd = 0.100;  //Variable
                double pipeId = 0.080;
                double pipeLength = 0.500;

                Circle2d c1 = prof.Circles2d.AddByCenterRadius(0, 0, pipeOd / 2.0);  
                Circle2d c2 = prof.Circles2d.AddByCenterRadius(0, 0, pipeId / 2.0);

                Line2d lv = (Line2d)prof.ProjectRefPlane(frontPln); //Reference line

                rels.AddKeypoint(c1, (int)igCircleCenter, lv, (int)igLineMiddle); 
                rels.AddKeypoint(c2, (int)igCircleCenter, lv, (int)igLineMiddle);

                Dimension dimOd = dim.AddCircularDiameter(c1); //Dimension
                dimOd.Constraint = true;
                dimOd.TrackDistance = 0.015;

                Dimension dimId = dim.AddCircularDiameter(c2);
                dimId.Constraint = true;
                dimId.TrackDistance = -0.015;

                // Profile closed
                int stat = prof.End(ProfileValidationType.igProfileClosed|ProfileValidationType.igProfileAllowNested);  
                Debug.Assert(stat == 0);

                for (int i = 1; i <= profs.Count; i++)  
                profs.Item(i).Visible = false;

                Profile[] profArr = new Profile[] { prof };
                Model mdl = Pdoc.Models.AddFiniteExtrudedProtrusion(1, profArr, FeaturePropertyConstants.igRight, pipeLength);

 

Re: Hollow Protrusion

Pioneer
Pioneer

Much appreciated VPJ19, exactly what I'm working on.

 

Thanks!

 

 

Re: Hollow Protrusion

Pioneer
Pioneer

Thanks MartinBernhard, your help got the code running.

 

Good work!!