Relationship problems between a sketch and a coordinate system.

[ Edited ]

I have been trying to add a sketch to an assembly using a coordinatesystem for place and orientation. Creating a plane and circle works fine, no problems here, but when I am trying to create a relation between the centre of the sketch and the coordinatesystem I can seem to find a reference to the coordinate system that works.


This is the code I am using, the hashmarks  are where I cant seem to find a suitable reference to the coordinate system. (when I tried adding a second circle, I could create a relation ship between the two sketches with out any problem)

public static void CreateCircleSketch(AssemblyDocument doc, string name, SolidEdgePart.CoordinateSystem coordinateSystem, double radius)
            Face face = (Face)coordinateSystem.Plane[SolidEdgePart.CoordinateSystemFeatureConstants.seCoordSysXYPlane];
            var refPlane = doc.AsmRefPlanes.AddParallelByDistance(face, 0, ReferenceElementConstants.igNormalSide, Type.Missing, Type.Missing, Type.Missing);
            refPlane.Name = string.Format("Plane {0}", name);

            object status = null;
            var layout = doc.Layouts.Add(refPlane, Type.Missing, out status);
            layout.Name = string.Format("Sketch {0}", name);

            var profile = (SolidEdgePart.Profile)layout.Profile;

            SolidEdgeFrameworkSupport.Circles2d circles2d = profile.Circles2d;

     double x = 0;
     double y = 0;

     SolidEdgeFrameworkSupport.Circle2d circle = circles2d.AddByCenterRadius(x, y, radius);

var rel2d = (Relations2d)profile.Relations2d;

rel2d.AddKeypoint(circle, 0, #######, #######);





Re: Relationship problems between a sketch and a coordinate system.

What I am basically try to do is the following, but in code not through the UI:


(view in My Videos)