public override void SaveFile(string path)
        {
            var svgDoc = new SpaceClaim.Svg.Document(path);

            Part mainPart = Window.ActiveWindow.Scene as Part;
            if (mainPart == null)
                return;

            Color? strokeColor;
            Color? fillColor = null;

            foreach (IDesignFace iDesignFace in mainPart.GetDescendants<IDesignFace>()) {
                Face face = iDesignFace.Master.Shape;
                strokeColor = iDesignFace.GetAncestor<IDesignBody>().GetVisibleColor();
                fillColor = Color.FromArgb(127, strokeColor.Value);

                foreach (Loop loop in face.Loops)
                    svgDoc.AddPath(loop.Fins.Select(f => (ITrimmedCurve) f.Edge).ToList(), true, 1, strokeColor, fillColor);
            }

            Dictionary<Layer, List<CurveSegment>> CurvesOnLayer = mainPart.GetCurvesByLayer();
            AddCurvesByLayer(svgDoc, fillColor, CurvesOnLayer);

            foreach (IComponent iComponent in mainPart.Components) {
                CurvesOnLayer = iComponent.GetCurvesByLayer();
                AddCurvesByLayer(svgDoc, fillColor, CurvesOnLayer);
            }

            svgDoc.SaveXml();
        }
Exemple #2
0
 private static void AddCurvesByLayer(SpaceClaim.Svg.Document svgDoc, Color?fillColor, Dictionary <Layer, List <CurveSegment> > CurvesOnLayer)
 {
     foreach (Layer layer in CurvesOnLayer.Keys)
     {
         List <List <ITrimmedCurve> > profiles = CurvesOnLayer[layer].Cast <ITrimmedCurve>().ToList().ExtractChains().Select(c => c.ToList()).ToList();
         foreach (List <ITrimmedCurve> profile in profiles)
         {
             svgDoc.AddPath(profile, false, GetLineWeight(layer.GetLineWeight(null)), layer.GetColor(null), fillColor);
         }
     }
 }
Exemple #3
0
        public override void SaveFile(string path)
        {
            var svgDoc = new SpaceClaim.Svg.Document(path);

            Part mainPart = Window.ActiveWindow.Scene as Part;

            if (mainPart == null)
            {
                return;
            }

            Color?strokeColor;
            Color?fillColor = null;

            foreach (IDesignFace iDesignFace in mainPart.GetDescendants <IDesignFace>())
            {
                Face face = iDesignFace.Master.Shape;
                strokeColor = iDesignFace.GetAncestor <IDesignBody>().GetVisibleColor();
                fillColor   = Color.FromArgb(127, strokeColor.Value);

                foreach (Loop loop in face.Loops)
                {
                    svgDoc.AddPath(loop.Fins.Select(f => (ITrimmedCurve)f.Edge).ToList(), true, 1, strokeColor, fillColor);
                }
            }


            Dictionary <Layer, List <CurveSegment> > CurvesOnLayer = mainPart.GetCurvesByLayer();

            AddCurvesByLayer(svgDoc, fillColor, CurvesOnLayer);

            foreach (IComponent iComponent in mainPart.Components)
            {
                CurvesOnLayer = iComponent.GetCurvesByLayer();
                AddCurvesByLayer(svgDoc, fillColor, CurvesOnLayer);
            }

            svgDoc.SaveXml();
        }