示例#1
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                if (jigUpdate)
                {
                    stair = MyFunctions.CreateStair3D(steps, riser, tread, landing, width, slope);
                }
                switch (jigStatus)
                {
                case 0:
                    geo.PushModelTransform(matDisplacement);
                    geo.Draw(stair);
                    geo.PopModelTransform();
                    break;

                case 1:
                    geo.PushModelTransform(matDisplacement.PreMultiplyBy(matRotation));
                    geo.Draw(stair);
                    geo.PopModelTransform();
                    break;;

                default: return(false);
                }
            }
            return(true);
        }
示例#2
0
 public MyJig2(int steps, double riser, double tread, double landing, double width, double slope)
 {
     this.stair   = MyFunctions.CreateStair3D(steps, riser, tread, landing, width, slope);
     this.steps   = steps;
     this.tread   = tread;
     this.riser   = riser;
     this.landing = landing;
     this.width   = width;
     this.slope   = slope;
 }
示例#3
0
        public void CreateSolidStair()
        {
            PromptResult pr;

            // Get default values
            BaseStairObject bsoStandard = MyFunctions.GetPropertySetDefinitionStairStandardValues();

            List <LayerObject> lstLayers = MyFunctions.GetLayerList();

            winCreateStair win = new winCreateStair(lstLayers, bsoStandard);
            Boolean        rtn = Application.ShowModalWindow(win).Value;

            if (rtn == false)
            {
                return;
            }

            LayerObject selectedLayer = win.CB_Layers.SelectedItem as LayerObject;

            try
            {
                BaseStairObject objStair = new BaseStairObject
                {
                    Id      = ObjectId.Null,
                    Name    = win.TB_Name.Text,
                    Steps   = Convert.ToInt32(win.TB_Steps.Text),
                    Tread   = Convert.ToDouble(win.TB_Tread.Text),
                    Riser   = Convert.ToDouble(win.TB_Riser.Text),
                    Landing = Convert.ToDouble(win.TB_Landing.Text),
                    Width   = Convert.ToDouble(win.TB_Width.Text),
                    Slope   = Convert.ToDouble(win.TB_Slope.Text)
                };
                MyJig2 jig = new MyJig2(objStair.Steps, objStair.Riser, objStair.Tread, objStair.Landing, objStair.Width, objStair.Slope);

                do
                {
                    // Get the value entered by the user
                    pr = ed.Drag(jig);

                    // Exit if the user presses ESC or cancels the command
                    if (pr.Status == PromptStatus.Cancel)
                    {
                        return;
                    }

                    if (pr.Status == PromptStatus.OK)
                    {
                        // Go to next phase
                        jig.jigStatus++;
                    }
                }while (jig.jigStatus < 2);

                if (pr.Status == PromptStatus.OK)
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        try
                        {
                            BlockTable bt      = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                            Solid3d    stair3d = MyFunctions.CreateStair3D(jig.steps, jig.riser, jig.tread, jig.landing, jig.width, jig.slope);
                            if (stair3d != null)
                            {
                                // Moving and adding to staircase drawing database
                                stair3d.TransformBy(jig.matDisplacement);
                                stair3d.TransformBy(jig.matRotation);
                                //update layer
                                stair3d.LayerId = selectedLayer.Id;

                                BlockTableRecord curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                                curSpace.AppendEntity(stair3d);
                                tr.AddNewlyCreatedDBObject(stair3d, true);

                                // Adding ParameterSet to Staircase
                                objStair.Id = stair3d.Id;
                                bool isCreated = MyFunctions.SetStairPropertiesToSolid(stair3d, objStair);
                            }
                        }
                        catch (System.Exception ex)
                        {
                            ed.WriteMessage(ex.ToString());
                        }
                        tr.Commit();
                    }
                }
            }
            catch
            {
                ed.WriteMessage("\n Something wrong");
            }
        }