Exemple #1
0
        /////////////////////////////////////////////////////////////
        // Use: Inserts new sketch in part and copies content
        //      from input sketch
        /////////////////////////////////////////////////////////////
        public static PlanarSketch InsertSketch(PartDocument doc,
                                                PlanarSketch sketch,
                                                UnitVector xAxis,
                                                UnitVector yAxis,
                                                Point basePoint)
        {
            PartComponentDefinition compDef =
                doc.ComponentDefinition;

            WorkAxis wa1 = compDef.WorkAxes.AddFixed(
                basePoint, xAxis, _ConstructionWorkFeature);

            WorkAxis wa2 = compDef.WorkAxes.AddFixed(
                basePoint, yAxis, _ConstructionWorkFeature);

            WorkPlane wp = compDef.WorkPlanes.AddByTwoLines(
                wa1, wa2, _ConstructionWorkFeature);

            WorkPoint origin = compDef.WorkPoints.AddFixed(
                basePoint, _ConstructionWorkFeature);

            PlanarSketch newSketch =
                compDef.Sketches.AddWithOrientation(
                    wp, wa1, true, true, origin, false);

            sketch.CopyContentsTo(newSketch as Sketch);

            return(newSketch);
        }