protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) { return(false); } short origCol = draw.SubEntityTraits.Color; if (_resizing) { // using (Solid3d cube = new Solid3d()) //{ try { //cube.CreateBox(0.5, 0.5, 0.5); _firstdraw = _firstdraw + 1; if (cube != null) { //int i = 20000; bool chk = false; //cube.TransformBy( // Matrix3d.Displacement( // _resizeLocation - Point3d.Origin // ) // ); // Draw the cursor draw.SubEntityTraits.Color = ColorIndex; cube.WorldDraw(draw); vRot = leftHand.GetVectorTo(rightHand);; // new Point3d(-3, 4, 0).GetVectorTo(new Point3d(-3, -4, 0)); //rightHand.GetVectorTo(leftHand); System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(0.2).TotalMilliseconds); //chk = (leftHand.Z < leftHip.Z); //while (true) //{ // if (chk) // break; //Point3d pt1 = rightHand - leftHand; cube.TransformBy(Matrix3d.Rotation(0.1, vRot, Point3d.Origin)); //} /*if (chk) * { * cube.TransformBy(Matrix3d.Rotation(1.046, vRot, leftHand)); * System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(2).TotalMilliseconds); * } */ //cube.TransformBy(Matrix3d.Rotation(0.5236, vRot, leftHand)); } // if(_changeaxis) // vRot = rightHand.GetVectorTo(leftHand); // cube.TransformBy(Matrix3d.Rotation(0.5236,vRot,leftHand)); // if (leftHand.Z > leftHip.Z) // _isRotate = false; } catch (System.Exception ex) { _doc.Editor.WriteMessage( "\nException: {0} - {1}", ex.Message, ex.InnerException ); } finally { draw.SubEntityTraits.Color = origCol; } // } return(true); } if (_isRotate) { cube.WorldDraw(draw); } // If we're currently drawing... if (_drawing) { Solid3d sol = null; try { // If we have vertices that haven't yet been drawn... if (_vertices.Count > 1 //&& //_vertices.Count - 1 > _lastDrawnVertex ) { // ... generate a tube if (GenerateTube(_profSide, _vertices, out sol)) { // We now need to break the pipe... // If it was created, add it to our list to draw _created.Add(sol); sol = null; // Clear all but the last vertex to draw from // next time ClearAllButLast(_vertices, 1); } } } catch { // If the tube generation failed... if (sol != null) { sol.Dispose(); } // Loop, creating the most recent successful tube we can bool succeeded = false; int n = 1; do { try { // Generate the previous, working tube using all // but the last points (if it fails, one more is // excluded per iteration, until we get a working // tube) GenerateTube( _profSide, GetAllButLast(_vertices, n++), out sol ); _created.Add(sol); sol = null; succeeded = true; } catch { } }while (!succeeded && n < _vertices.Count); if (succeeded) { ClearAllButLast(_vertices, n - 1); if (_vertices.Count > 1) { try { // And generate a tube for the remaining vertices GenerateTube(_profSide, _vertices, out sol); } catch { succeeded = false; } } } if (!succeeded && sol != null) { sol.Dispose(); sol = null; } } // Draw our solid(s) draw.SubEntityTraits.Color = ColorIndex; foreach (DBObject obj in _created) { Entity ent = obj as Entity; if (ent != null) { try { ent.WorldDraw(draw); } catch { } } } if (sol != null) { try { sol.WorldDraw(draw); } catch { } } if (_vertices.Count > 0) { Point3d lastPt = _vertices[_vertices.Count - 1]; // Create a cursor sphere using (Solid3d cursor = new Solid3d()) { try { cursor.CreateBox(_profSide, _profSide, _profSide); if (cursor != null) { cursor.TransformBy( Matrix3d.Displacement(lastPt - Point3d.Origin) ); // Draw the cursor draw.SubEntityTraits.Color = 4; // ColorIndex; cursor.WorldDraw(draw); } } catch { } } } if (sol != null) { sol.Dispose(); } } draw.SubEntityTraits.Color = origCol; return(true); }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) { return(false); } short origCol = draw.SubEntityTraits.Color; if (_resizing) { using (Solid3d cube = new Solid3d()) { try { if (switchm == 1) { cube.CreateFrustum(_profSide, _profSide, _profSide, 0.0); } else if (switchm == 0) { cube.CreateBox(_profSide, _profSide, _profSide); } if (cube != null) { cube.TransformBy( Matrix3d.Displacement( _resizeLocation - Point3d.Origin ) ); // Draw the cursor draw.SubEntityTraits.Color = ColorIndex; cube.WorldDraw(draw); } } catch (System.Exception ex) { _doc.Editor.WriteMessage( "\nException: {0} - {1}", ex.Message, ex.InnerException ); } finally { draw.SubEntityTraits.Color = origCol; } } return(true); } // If we're currently drawing... if (_drawing) { Solid3d sol = null; try { // If we have vertices that haven't yet been drawn... if (_vertices.Count > 1 //&& //_vertices.Count - 1 > _lastDrawnVertex ) { // ... generate a tube if (GenerateTube(_profSide, _vertices, out sol)) { // We now need to break the pipe... // If it was created, add it to our list to draw _created.Add(sol); sol = null; // Clear all but the last vertex to draw from // next time ClearAllButLast(_vertices, 1); } } } catch { // If the tube generation failed... if (sol != null) { sol.Dispose(); } // Loop, creating the most recent successful tube we can bool succeeded = false; int n = 1; do { try { // Generate the previous, working tube using all // but the last points (if it fails, one more is // excluded per iteration, until we get a working // tube) GenerateTube( _profSide, GetAllButLast(_vertices, n++), out sol ); _created.Add(sol); sol = null; succeeded = true; } catch { } }while (!succeeded && n < _vertices.Count); if (succeeded) { ClearAllButLast(_vertices, n - 1); if (_vertices.Count > 1) { try { // And generate a tube for the remaining vertices GenerateTube(_profSide, _vertices, out sol); } catch { succeeded = false; } } } if (!succeeded && sol != null) { sol.Dispose(); sol = null; } } // Draw our solid(s) draw.SubEntityTraits.Color = ColorIndex; foreach (DBObject obj in _created) { Entity ent = obj as Entity; if (ent != null) { try { ent.WorldDraw(draw); } catch { } } } if (sol != null) { try { sol.WorldDraw(draw); } catch { } } if (_vertices.Count > 0) { Point3d lastPt = _vertices[_vertices.Count - 1]; // Create a cursor sphere using (Solid3d cursor = new Solid3d()) { try { if (switchm == 1) { cursor.CreateFrustum(_profSide, _profSide, _profSide, 0.0); } else if (switchm == 0) { cursor.CreateBox(_profSide, _profSide, _profSide); } if (cursor != null) { cursor.TransformBy( Matrix3d.Displacement(lastPt - Point3d.Origin) ); // Draw the cursor draw.SubEntityTraits.Color = 4; // ColorIndex; cursor.WorldDraw(draw); } } catch { } } } if (sol != null) { sol.Dispose(); } } draw.SubEntityTraits.Color = origCol; return(true); }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) return false; short origCol = draw.SubEntityTraits.Color; if (_resizing) { using (Solid3d cylinder = new Solid3d()) { try { cylinder.CreateFrustum(_profSide, _profSide, _profSide,_profSide); if (cylinder != null) { cylinder.TransformBy( Matrix3d.Displacement( _resizeLocation - Point3d.Origin ) ); // Draw the cursor draw.SubEntityTraits.Color = ColorIndex; cylinder.WorldDraw(draw); } } catch (System.Exception ex) { _doc.Editor.WriteMessage( "\nException: {0} - {1}", ex.Message, ex.InnerException ); } finally { draw.SubEntityTraits.Color = origCol; } } return true; } // If we're currently drawing... if (_drawing) { Solid3d sol = null; try { // If we have vertices that haven't yet been drawn... if (_vertices.Count > 1 //&& //_vertices.Count - 1 > _lastDrawnVertex ) { // ... generate a tube if (GenerateTube(_profSide, _vertices, out sol)) { // We now need to break the pipe... // If it was created, add it to our list to draw _created.Add(sol); sol = null; // Clear all but the last vertex to draw from // next time ClearAllButLast(_vertices, 1); } } } catch { // If the tube generation failed... if (sol != null) { sol.Dispose(); } // Loop, creating the most recent successful tube we can bool succeeded = false; int n = 1; do { try { // Generate the previous, working tube using all // but the last points (if it fails, one more is // excluded per iteration, until we get a working // tube) GenerateTube( _profSide, GetAllButLast(_vertices, n++), out sol ); _created.Add(sol); sol = null; succeeded = true; } catch { } } while (!succeeded && n < _vertices.Count); if (succeeded) { ClearAllButLast(_vertices, n - 1); if (_vertices.Count > 1) { try { // And generate a tube for the remaining vertices GenerateTube(_profSide, _vertices, out sol); } catch { succeeded = false; } } } if (!succeeded && sol != null) { sol.Dispose(); sol = null; } } // Draw our solid(s) draw.SubEntityTraits.Color = ColorIndex; foreach (DBObject obj in _created) { Entity ent = obj as Entity; if (ent != null) { try { ent.WorldDraw(draw); } catch { } } } if (sol != null) { try { sol.WorldDraw(draw); } catch { } } if (_vertices.Count > 0) { Point3d lastPt = _vertices[_vertices.Count - 1]; // Create a cursor sphere using (Solid3d cursor = new Solid3d()) { try { cursor.CreateFrustum(_profSide, _profSide, _profSide, _profSide ); if (cursor != null) { cursor.TransformBy( Matrix3d.Displacement(lastPt - Point3d.Origin) ); // Draw the cursor draw.SubEntityTraits.Color = 5; //ColorIndex; cursor.WorldDraw(draw); } } catch { } } } if (sol != null) { sol.Dispose(); } } draw.SubEntityTraits.Color = origCol; return true; }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) { return(false); } short origCol = draw.SubEntityTraits.Color; // If we're currently drawing... if (_drawing) { try { // Let's start by creating our spline path if ((_path == null && _vertices.Count > 1) || (_path != null && _vertices.Count > _path.NumFitPoints)) { if (_path != null) { _path.Dispose(); } _path = new Spline(_vertices, 0, 0.0); // And our sweep profile, if we don't have one if (_profile != null) { _profile.Dispose(); } _profile = new Circle( _vertices[0], _vertices[1] - _vertices[0], _profRad ); // And our sweep options, if we don't have one if (_sweepOpts == null) { var sob = new SweepOptionsBuilder(); // Align the entity to sweep to the path sob.Align = SweepOptionsAlignOption.AlignSweepEntityToPath; // The base point is the start of the path sob.BasePoint = _path.StartPoint; // The profile will rotate to follow the path sob.Bank = true; _sweepOpts = sob.ToSweepOptions(); } // Finally create a blank solid, if it's null if (_tube == null) { _tube = new Solid3d(); } // And sweep our profile along our path _tube.CreateSweptSolid(_profile, _path, _sweepOpts); } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { _sweepBroken = true; _tube.Dispose(); _tube = null; _doc.Editor.WriteMessage( "\nException: {0}", ex.Message ); } // Draw our path, if we have one if (_path != null) { draw.SubEntityTraits.Color = transPathColor; _path.WorldDraw(draw); } // And our solid if (_tube != null) { draw.SubEntityTraits.Color = transSolColor; _tube.WorldDraw(draw); } if (_vertices.Count > 0) { // Get the last point (at which our cursor should // be located, if it exists) var lastPt = _vertices[_vertices.Count - 1]; if (_cursor == null) { // Create a cursor sphere _cursor = new Solid3d(); ((Solid3d)_cursor).CreateSphere(_profRad); _curPt = Point3d.Origin; } // Move it to the current point _cursor.TransformBy( Matrix3d.Displacement(lastPt - _curPt) ); _curPt = lastPt; // Draw the cursor draw.SubEntityTraits.Color = (_sweepBroken ? transPathColor : transSolColor); _cursor.WorldDraw(draw); } } draw.SubEntityTraits.Color = origCol; return(true); }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) return false; short origCol = draw.SubEntityTraits.Color; // If we're currently drawing... if (_drawing) { try { // Let's start by creating our spline path if ((_path == null && _vertices.Count > 1) || (_path != null && _vertices.Count > _path.NumFitPoints)) { if (_path != null) _path.Dispose(); _path = new Spline(_vertices, 0, 0.0); // And our sweep profile, if we don't have one if (_profile != null) _profile.Dispose(); _profile = new Circle( _vertices[0], _vertices[1] - _vertices[0], _profRad ); // And our sweep options, if we don't have one if (_sweepOpts == null) { SweepOptionsBuilder sob = new SweepOptionsBuilder(); // Align the entity to sweep to the path sob.Align = SweepOptionsAlignOption.AlignSweepEntityToPath; // The base point is the start of the path sob.BasePoint = _path.StartPoint; // The profile will rotate to follow the path sob.Bank = true; _sweepOpts = sob.ToSweepOptions(); } // Finally create a blank solid, if it's null if (_tube == null) _tube = new Solid3d(); // And sweep our profile along our path _tube.CreateSweptSolid(_profile, _path, _sweepOpts); } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { _sweepBroken = true; _tube.Dispose(); _tube = null; _doc.Editor.WriteMessage( "\nException: {0}", ex.Message ); } // Draw our path, if we have one if (_path != null) { draw.SubEntityTraits.Color = transPathColor; _path.WorldDraw(draw); } // And our solid if (_tube != null) { draw.SubEntityTraits.Color = transSolColor; _tube.WorldDraw(draw); } if (_vertices.Count > 0) { // Get the last point (at which our cursor should // be located, if it exists) Point3d lastPt = _vertices[_vertices.Count - 1]; if (_cursor == null) { // Create a cursor sphere _cursor = new Solid3d(); ((Solid3d)_cursor).CreateSphere(_profRad); _curPt = Point3d.Origin; } // Move it to the current point _cursor.TransformBy( Matrix3d.Displacement(lastPt - _curPt) ); _curPt = lastPt; // Draw the cursor draw.SubEntityTraits.Color = (_sweepBroken ? transPathColor : transSolColor); _cursor.WorldDraw(draw); } } draw.SubEntityTraits.Color = origCol; return true; }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) return false; short origCol = draw.SubEntityTraits.Color; if (_resizing) { // using (Solid3d cube = new Solid3d()) //{ try { //cube.CreateBox(0.5, 0.5, 0.5); _firstdraw = _firstdraw + 1; if (cube != null) { //int i = 20000; bool chk = false; //cube.TransformBy( // Matrix3d.Displacement( // _resizeLocation - Point3d.Origin // ) // ); // Draw the cursor draw.SubEntityTraits.Color = ColorIndex; cube.WorldDraw(draw); vRot = leftHand.GetVectorTo(rightHand); ;// new Point3d(-3, 4, 0).GetVectorTo(new Point3d(-3, -4, 0)); //rightHand.GetVectorTo(leftHand); System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(0.2).TotalMilliseconds); //chk = (leftHand.Z < leftHip.Z); //while (true) //{ // if (chk) // break; //Point3d pt1 = rightHand - leftHand; cube.TransformBy(Matrix3d.Rotation(0.1, vRot, Point3d.Origin)); //} /*if (chk) { cube.TransformBy(Matrix3d.Rotation(1.046, vRot, leftHand)); System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(2).TotalMilliseconds); } */ //cube.TransformBy(Matrix3d.Rotation(0.5236, vRot, leftHand)); } // if(_changeaxis) // vRot = rightHand.GetVectorTo(leftHand); // cube.TransformBy(Matrix3d.Rotation(0.5236,vRot,leftHand)); // if (leftHand.Z > leftHip.Z) // _isRotate = false; } catch (System.Exception ex) { _doc.Editor.WriteMessage( "\nException: {0} - {1}", ex.Message, ex.InnerException ); } finally { draw.SubEntityTraits.Color = origCol; } // } return true; } if (_isRotate) { cube.WorldDraw(draw); } // If we're currently drawing... if (_drawing) { Solid3d sol = null; try { // If we have vertices that haven't yet been drawn... if (_vertices.Count > 1 //&& //_vertices.Count - 1 > _lastDrawnVertex ) { // ... generate a tube if (GenerateTube(_profSide, _vertices, out sol)) { // We now need to break the pipe... // If it was created, add it to our list to draw _created.Add(sol); sol = null; // Clear all but the last vertex to draw from // next time ClearAllButLast(_vertices, 1); } } } catch { // If the tube generation failed... if (sol != null) { sol.Dispose(); } // Loop, creating the most recent successful tube we can bool succeeded = false; int n = 1; do { try { // Generate the previous, working tube using all // but the last points (if it fails, one more is // excluded per iteration, until we get a working // tube) GenerateTube( _profSide, GetAllButLast(_vertices, n++), out sol ); _created.Add(sol); sol = null; succeeded = true; } catch { } } while (!succeeded && n < _vertices.Count); if (succeeded) { ClearAllButLast(_vertices, n - 1); if (_vertices.Count > 1) { try { // And generate a tube for the remaining vertices GenerateTube(_profSide, _vertices, out sol); } catch { succeeded = false; } } } if (!succeeded && sol != null) { sol.Dispose(); sol = null; } } // Draw our solid(s) draw.SubEntityTraits.Color = ColorIndex; foreach (DBObject obj in _created) { Entity ent = obj as Entity; if (ent != null) { try { ent.WorldDraw(draw); } catch { } } } if (sol != null) { try { sol.WorldDraw(draw); } catch { } } if (_vertices.Count > 0) { Point3d lastPt = _vertices[_vertices.Count - 1]; // Create a cursor sphere using (Solid3d cursor = new Solid3d()) { try { cursor.CreateBox(_profSide, _profSide, _profSide); if (cursor != null) { cursor.TransformBy( Matrix3d.Displacement(lastPt - Point3d.Origin) ); // Draw the cursor draw.SubEntityTraits.Color = 4; // ColorIndex; cursor.WorldDraw(draw); } } catch { } } } if (sol != null) { sol.Dispose(); } } draw.SubEntityTraits.Color = origCol; return true; }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) { return(false); } short origCol = draw.SubEntityTraits.Color; if (_isExtrude) { // using (Solid3d cube = new Solid3d()) //{ try { //cube.CreateBox(0.5, 0.5, 0.5); _firstdraw = _firstdraw + 1; if (cube != null) { //int i = 20000; bool chk = false; //cube.TransformBy( // Matrix3d.Displacement( // _resizeLocation - Point3d.Origin // ) // ); // Draw the cursor draw.SubEntityTraits.Color = ColorIndex; cube.WorldDraw(draw); //vRot = leftHand.GetVectorTo(rightHand); ;// new Point3d(-3, 4, 0).GetVectorTo(new Point3d(-3, -4, 0)); //rightHand.GetVectorTo(leftHand); System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(0.2).TotalMilliseconds); //chk = (leftHand.Z < leftHip.Z); //while (true) //{ // if (chk) // break; //Point3d pt1 = rightHand - leftHand; //cube.TransformBy(Matrix3d.Rotation(0.1, vRot, Point3d.Origin)); //} /*if (chk) * { * cube.TransformBy(Matrix3d.Rotation(1.046, vRot, leftHand)); * System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(2).TotalMilliseconds); * } */ //cube.TransformBy(Matrix3d.Rotation(0.5236, vRot, leftHand)); } // if(_changeaxis) // vRot = rightHand.GetVectorTo(leftHand); // cube.TransformBy(Matrix3d.Rotation(0.5236,vRot,leftHand)); // if (leftHand.Z > leftHip.Z) // _isRotate = false; } catch (System.Exception ex) { _doc.Editor.WriteMessage( "\nException: {0} - {1}", ex.Message, ex.InnerException ); } finally { draw.SubEntityTraits.Color = origCol; } // } return(true); } // if (_isExtrude) // { cube.WorldDraw(draw); cube.ExtrudeFaces(AcArray <AcDbSubentId *>& { 1 }, _profSide, 1.6);