public override hresult PlaceObject(PlaceFlags lInsertType) { InputJig jig = new InputJig(); InputResult res = jig.SelectObject("Select Line"); if (res.Result != InputResult.ResultCode.Normal) { return(hresult.e_Fail); } LineSeg3d line = res.Geometry.LineSeg; _pnt1 = line.StartPoint; _pnt2 = line.EndPoint; McObjectId id = res.ObjectId; DbGeometry selection = id.GetObject(); //if (selection.IsKindOf(DbPolyline.TypeID)) //{ // MessageBox.Show("poly"); //} //else if (selection.IsKindOf(DbLine.TypeID)) //{ // MessageBox.Show("line"); //} //else //{ // MessageBox.Show("Objecttype isn't valid"); // DbEntity.Erase(); // return hresult.e_Fail; //} DbEntity.AddToCurrentDocument(); return(hresult.s_Ok); }
public override hresult PlaceObject(PlaceFlags lInsertType) { InputJig jig = new InputJig(); InputResult res = jig.GetPoint("Select first point:"); if (res.Result != InputResult.ResultCode.Normal) { return(hresult.e_Fail); } _pnt = res.Point; DbEntity.AddToCurrentDocument(); //Exclude this from osnap to avoid osnap to itself jig.ExcludeObject(ID); //Monitor mouse move jig.MouseMove = (s, a) => { TryModify(); _pnt2 = a.Point; _pnt3 = new Point3d(_pnt2.X, _pnt.Y, 0); _pnt1 = new Point3d(_pnt.X, _pnt2.Y, 0); DbEntity.Update(); }; res = jig.GetPoint("Select second point:", res.Point); if (res.Result != InputResult.ResultCode.Normal) { DbEntity.Erase(); return(hresult.e_Fail); } _pnt2 = res.Point; _pnt1 = new Point3d(_pnt.X, _pnt2.Y, 0); _pnt3 = new Point3d(_pnt2.X, _pnt.Y, 0); return(hresult.s_Ok); }
public override hresult PlaceObject(PlaceFlags lInsertType) { InputJig jig = new InputJig(); // Get the first box point from the jig InputResult res = jig.GetPoint("Select first point:"); if (res.Result != InputResult.ResultCode.Normal) { return(hresult.e_Fail); } _pnt1 = res.Point; // Add the object to the database this.DbEntity.AddToCurrentDocument(); //Exclude the object from snap points jig.ExcludeObject(ID); // Monitoring mouse moving and interactive entity redrawing jig.MouseMove = (s, a) => { TryModify(); _pnt2 = a.Point; this.DbEntity.Update(); }; // Get the second box point from the jig res = jig.GetPoint("Select second point:"); if (res.Result != InputResult.ResultCode.Normal) { this.DbEntity.Erase(); return(hresult.e_Fail); } _pnt2 = res.Point; return(hresult.s_Ok); }
public override hresult PlaceObject(PlaceFlags lInsertType) { InputJig jig = new InputJig(); // Get the first box point from the jig InputResult res = jig.GetPoint("Select first point:"); if (res.Result != InputResult.ResultCode.Normal) return hresult.e_Fail; _pnt1 = res.Point; // Add the object to the database DbEntity.AddToCurrentDocument(); return hresult.s_Ok; }
public override hresult PlaceObject(PlaceFlags lInsertType) { InputJig jig = new InputJig(); InputResult res = jig.GetPoint("Select first point:"); if (res.Result != InputResult.ResultCode.Normal) { return(hresult.e_Fail); } poly = new Polyline3d(); poly.Vertices.AddVertex(res.Point); poly.Vertices.AddVertex(res.Point); _textPoint = new Point3d(res.Point.X, res.Point.Y - 5 - Thickness, 0); Polyline3d.VertexDataOfPolyline polyVertecies = poly.Vertices; //_points.Add(res.Point); //_points.Add(res.Point); //Bug double? DbEntity.AddToCurrentDocument(); //Exclude this from osnap to avoid osnap to itself jig.ExcludeObject(ID); //Monitor mouse move jig.MouseMove = (s, a) => { TryModify(); //_points[_points.Count-1] = a.Point; //polyVertecies[polyVertecies.Count - 1].Point = a.Point; polyVertecies.RemoveVertexAt(uint.Parse((polyVertecies.Count - 1).ToString())); polyVertecies.AddVertex(a.Point); DbEntity.Update(); }; while (res.Result == InputResult.ResultCode.Normal) { res = jig.GetPoint("Select next point(" + polyVertecies.Count + "):", res.Point); //_points.Add(res.Point); poly.Vertices.AddVertex(res.Point); } DbEntity.Erase(); polyVertecies.RemoveVertexAt(uint.Parse((polyVertecies.Count - 1).ToString())); polyVertecies.RemoveVertexAt(uint.Parse((polyVertecies.Count - 1).ToString())); DbEntity.AddToCurrentDocument(); return(hresult.s_Ok); }
public override hresult PlaceObject(PlaceFlags lInsertType) { InputJig jig = new InputJig(); InputResult res = jig.SelectObject("Select Line"); if (res.Result != InputResult.ResultCode.Normal) { return(hresult.e_Fail); } LineSeg3d line = res.Geometry.LineSeg; poly = new Polyline3d(line); McObjectId id = res.ObjectId; DbGeometry selection = id.GetObject(); DbEntity.AddToCurrentDocument(); return(hresult.s_Ok); }
public override hresult PlaceObject(PlaceFlags lInsertType) { InputJig jig = new InputJig(); List <McObjectId> SelectObjects = jig.SelectObjects("Select Object"); //InputResult res = jig.SelectObject("Select a Polyline"); //McObjectId id = SelectObjects[0];//.ObjectId; //DbGeometry selection = id.GetObject(); if (SelectObjects.Count == 0) { DbEntity.Erase(); return(hresult.e_Fail); } McDocument document = McDocumentsManager.GetActiveDoc(); McDocument block = document.CreateBlock("ArrayBlock", true); _block_name = block.Name; InputResult res = jig.GetPoint("Select Base Point:"); foreach (McObjectId obj in SelectObjects) { McDbObject item = obj.GetObject(); item.Entity.DbEntity.Transform(Matrix3d.Displacement(res.Point.GetAsVector().MultiplyBy(-1))); block.AddObject(item.Clone()); } _idRef = document.GetBlock(_block_name); res = jig.GetPoint("Select first point:"); if (res.Result != InputResult.ResultCode.Normal) { return(hresult.e_Fail); } _pnt1 = res.Point; foreach (McObjectId obj in SelectObjects) { McDbObject item = obj.GetObject(); item.Erase(); } McBlockRef blockref = new McBlockRef(); blockref.BlockName = _block_name; blockref.InsertPoint = res.Point; blockref.DbEntity.AddToCurrentDocument(); _blockRef.Add(blockref); _blockRef.Add(_blockRef[0].DbEntity.Clone()); _blockRef.Add(_blockRef[0].DbEntity.Clone()); DbEntity.AddToCurrentDocument(); //Exclude this from osnap to avoid osnap to itself jig.ExcludeObject(ID); //Monitor mouse move jig.MouseMove = (s, a) => { TryModify(); _pnt2 = a.Point; DbEntity.Update(); }; res = jig.GetPoint("Select second point:", res.Point); if (res.Result != InputResult.ResultCode.Normal) { DbEntity.Erase(); blockref.DbEntity.Erase(); return(hresult.e_Fail); } _pnt2 = res.Point; Editor ed = HostMgd.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; PromptIntegerOptions opts = new PromptIntegerOptions("Enter Count number: "); opts.AllowNegative = false; opts.AllowZero = false; opts.DefaultValue = 1; PromptIntegerResult pr = ed.GetInteger(opts); if (PromptStatus.OK == pr.Status) { ed.WriteMessage("You entered: " + pr.StringResult); _count = pr.Value; _blockRef.Add(blockref.DbEntity.Clone()); _blockRef[1].InsertPoint = res.Point; _blockRef[1].DbEntity.AddToCurrentDocument(); } else { _count = 1; _blockRef.Add(blockref.DbEntity.Clone()); _blockRef[1].InsertPoint = res.Point; _blockRef[1].DbEntity.AddToCurrentDocument(); } for (int i = 1; i < Count; i++) { _blockRef.Add(_blockRef[0].DbEntity.Clone()); } return(hresult.s_Ok); }
public void DrawXThree() { Point3d _pntBase; Point3d _bufPnt; //prompts for installation point entry InputJig jig = new InputJig(); // Get the first box point from the jig InputResult res = jig.GetPoint("Select first point:"); //It works only if input was successful if (res.Result == InputResult.ResultCode.Normal) { // The base point is taken from the entry point (click with mouse) _pntBase = res.Point; //Draw the outline of the left half of the Christmas tree //Create base points for the polyline List <Point3d> leftPatrOfThreePoints = new List <Point3d>() { new Point3d(_pntBase.X, _pntBase.Y, 0), new Point3d(_pntBase.X - 125, _pntBase.Y - 154, 0), new Point3d(_pntBase.X - 31, _pntBase.Y - 137, 0), new Point3d(_pntBase.X - 181, _pntBase.Y - 287, 0), new Point3d(_pntBase.X - 31, _pntBase.Y - 253, 0), new Point3d(_pntBase.X - 242, _pntBase.Y - 400, 0), new Point3d(_pntBase.X - 37, _pntBase.Y - 400, 0), new Point3d(_pntBase.X - 37, _pntBase.Y - 454, 0), new Point3d(_pntBase.X, _pntBase.Y - 454, 0) }; //Create a polyline (geometry) Polyline3d leftPatrOfThree = new Polyline3d(leftPatrOfThreePoints); //Create a polyline object and place it on the drawing DbPolyline XThreeLeft = new DbPolyline(); XThreeLeft.Polyline = new Polyline3d(leftPatrOfThree); XThreeLeft.Polyline.SetClosed(false); XThreeLeft.DbEntity.Color = Color.Green; XThreeLeft.DbEntity.AddToCurrentDocument(); //The right part of the tree is obtained by mirroring the left DbPolyline XThreeRight = new DbPolyline(); XThreeRight.DbEntity.Color = Color.Green; XThreeRight.Polyline = (Polyline3d)XThreeLeft.Polyline.Mirror(new Plane3d(_pntBase, new Vector3d(10, 0, 0))); XThreeRight.DbEntity.AddToCurrentDocument(); //From the right and left sides we make a single contour for hatching DbPolyline XThreeR = new DbPolyline(); XThreeR.DbEntity.Color = Color.Green; XThreeR.Polyline = XThreeRight.Polyline.GetCopy() as Polyline3d; XThreeR.DbEntity.AddToCurrentDocument(); List <Point3d> hatchPoints = new List <Point3d>(); hatchPoints.AddRange(leftPatrOfThreePoints); hatchPoints.AddRange(XThreeR.Polyline.Points.Reverse().ToList()); Polyline3d hatchContur = new Polyline3d(hatchPoints); //We will create on the basis of a contour a hatch (geometry) with continuous filling Hatch hatch = new Hatch(hatchContur, 0, 10, true); hatch.PattType = PatternType.PreDefined; hatch.PatternName = "SOLID"; //Based on the geometry of the hatch, we create the document object, set its color properties - green DbGeometry dbhatch = new DbGeometry(); dbhatch.Geometry = new EntityGeometry(hatch); dbhatch.DbEntity.Color = Color.Green; dbhatch.DbEntity.AddToCurrentDocument(); // if you want you can try to draw balls with circles use // DrawThreeBalls(_pntBase); //Similarly, make a Christmas tree toy (octagon) //red _bufPnt = _pntBase.Subtract(new Vector3d(30, 95, 0)); DbPolyline dbOctoRed = DrawThreeOctogonPl(_bufPnt);//implicit dbOctoRed.DbEntity.AddToCurrentDocument(); Hatch hatchCirkRed = new Hatch(dbOctoRed.Polyline, 0, 1, false); hatchCirkRed.PattType = PatternType.PreDefined; hatchCirkRed.PatternName = "SOLID"; DbGeometry dbhatchCirkRed = new DbGeometry(); dbhatchCirkRed.Geometry = new EntityGeometry(hatchCirkRed); dbhatchCirkRed.DbEntity.Color = Color.Red; dbhatchCirkRed.DbEntity.AddToCurrentDocument(); //green _bufPnt = _pntBase.Subtract(new Vector3d(-40, 200, 0)); DbPolyline dbOctoGreen = DrawThreeOctogonPl(_bufPnt);//implicit dbOctoGreen.DbEntity.AddToCurrentDocument(); Hatch hatchCirkGreen = new Hatch(dbOctoGreen.Polyline, 0, 1, false); hatchCirkGreen.PattType = PatternType.PreDefined; hatchCirkGreen.PatternName = "SOLID"; DbGeometry dbhatchCirkGreen = new DbGeometry(); dbhatchCirkGreen.Geometry = new EntityGeometry(hatchCirkGreen); dbhatchCirkGreen.DbEntity.Color = Color.LightSeaGreen; dbhatchCirkGreen.DbEntity.AddToCurrentDocument(); //blue _bufPnt = _pntBase.Subtract(new Vector3d(-12, 350, 0)); DbPolyline dbOctoBlue = DrawThreeOctogonPl(_bufPnt);//implicit dbOctoBlue.DbEntity.AddToCurrentDocument(); Hatch hatchCirkBlue = new Hatch(dbOctoBlue.Polyline, 0, 1, false); hatchCirkBlue.PattType = PatternType.PreDefined; hatchCirkBlue.PatternName = "SOLID"; DbGeometry dbhatchCirkBlue = new DbGeometry(); dbhatchCirkBlue.Geometry = new EntityGeometry(hatchCirkBlue); dbhatchCirkBlue.DbEntity.Color = Color.Blue; dbhatchCirkBlue.DbEntity.AddToCurrentDocument(); //display the text with congratulations MessageBox.Show("I Wish You A Merry Christmas And Happy New Year!"); } }
public void DrawFace() { //We draw half of face // Draw eye DbCircle eye = new DbCircle(); eye.Radius = 100; eye.Center = new Point3d(200, 500, 0); eye.DbEntity.AddToCurrentDocument(); //Draw nose DbLine nose = new DbLine(); nose.StartPoint = new Point3d(350, 400, 0); nose.EndPoint = new Point3d(350, 200, 0); nose.DbEntity.AddToCurrentDocument(); //Draw mouth DbPolyline mouth = new DbPolyline(); List <Point3d> mouthPoints = new List <Point3d>() { new Point3d(100, 150, 0), new Point3d(200, 100, 0), new Point3d(350, 100, 0) }; mouth.Polyline = new Polyline3d(mouthPoints); mouth.Polyline.SetClosed(false); mouth.DbEntity.Transform(McDocumentsManager.GetActiveDoc().UCS); //change coordinates from UCS to WCS for BD mouth.DbEntity.AddToCurrentDocument(); //draw mirror half the face (2nd half) DbCircle eye2 = new DbCircle(); eye2.Radius = 100; eye2.Center = new Point3d(500, 500, 0); eye2.DbEntity.AddToCurrentDocument(); DbPolyline mouth2 = new DbPolyline(); mouth2.Polyline = mouth.Polyline.Mirror(new Plane3d(new Point3d(350, 100, 0), new Vector3d(200, 0, 0))) as Polyline3d; mouth2.DbEntity.AddToCurrentDocument(); //Get notification in command line McContext.ShowNotification("You need to enter data into the console"); //Get uaser input InputJig editorInput = new InputJig(); string name = editorInput.GetText("Input your name and press Enter"); //Drawing face's text DbText spech = new DbText(); spech.Text = new TextGeom("Oh Master! Why I'm so ugly? Please remove me!", new Point3d(510, 15, 0), Vector3d.XAxis, "Standard", 15); spech.DbEntity.AddToCurrentDocument(); //Get windows message box MessageBox.Show("Congratulation " + name + " you did it! But look, it want, to say something to you..."); //Get popup help McContext.PopupNotification("Delete command has activated"); //Activate another command (Delete) McContext.ExecuteCommand("Delete"); }