示例#1
0
        protected override object Regenerate(IModeler modeler)
        {
            SwFeatureData.EnableMultiBodyConsume = true;

            if (Database.Style == MulitWireBodiesData.StyleEnum.Wire)
            {
                var w = _R.NextDouble();

                var line0 = modeler.CreateTrimmedLine(new Vector3(0, -w, 0), new Vector3(1, -w, 0));
                var line1 = modeler.CreateTrimmedLine(new Vector3(0, w, 0), new Vector3(1, w, 0));

                var wire0 = line0.CreateWireBody();
                var wire1 = line1.CreateWireBody();

                SwFeatureData.AddIdsToBody(wire0);
                SwFeatureData.AddIdsToBody(wire1);

                return(new[] { wire0, wire1 });
            }
            else
            {
                var solid0 = modeler.CreateBox(new Vector3(0, 0, 0), Vector3.UnitX, 1, 1, 1);
                var solid1 = modeler.CreateBox(new Vector3(2, 0, 0), Vector3.UnitX, 1, 1, 1);

                SwFeatureData.AddIdsToBody(solid0);
                SwFeatureData.AddIdsToBody(solid0);

                return(new[] { solid0, solid1 });
            }
        }
        protected override object Regenerate(IModeler modeler)
        {
            return(Database.Body
                   .GetSingleObject <IBody2>(ModelDoc)
                   .MatchUnsafe <object>(bodyFn =>
            {
                var body = (IBody2)bodyFn().Copy();
                SwFeatureData.EnableMultiBodyConsume = true;
                var splitBodies = SplitBodies(modeler, body, Database);
                if (splitBodies == null)
                {
                    return "There was some error";
                }

                foreach (var splitBody in splitBodies)
                {
                    SwFeatureData.AddIdsToBody(splitBody);
                }

                return splitBodies;
            }, () => null));
        }