I have programmatically created a block, which resembles the protective tube schematically drawn. The block consists of two ellipses of connected the two lines. This block tries to modify (also programmable). The modification consists of changing the position of the ellipse and the length of the line. Everything (almost) goes smoothly, until the pipe extends beyond its original length. The changes are visible, but I'm not able to pick the block beyond its original contour. So I can pick out such lines, if picked point is on the original length, but beyond its original length is not already. The same applies to the ellipse. The situation returned to normal, if I tried stretch the block (base point) or command _move. Regeneration of the model does not work.
I throw a piece of code:
using( Transaction tr = doc.TransactionManager.StartTransaction() ) { //Block? Entity ent = tr.GetObject( per.ObjectId, OpenMode.ForRead ) as Entity; (...) BlockReference blRef = ent as BlockReference; (...) Ellipse ell1 = null; Ellipse ell2 = null; Line line1 = null; Line line2 = null; BlockTableRecord btr = tr.GetObject( blRef.BlockTableRecord, OpenMode.ForRead ) as BlockTableRecord; foreach( ObjectId entId in btr ) { Entity btrEnt = tr.GetObject( entId, OpenMode.ForRead ) as Entity; if( btrEnt.GetType() == typeof( Ellipse ) ) { if( ell1 == null ) ell1 = btrEnt as Ellipse; else ell2 = btrEnt as Ellipse; } //if( btrEnt.GetType() == typeof( Ellipse ) ) else if( btrEnt.GetType() == typeof( Line ) ) { if( line1 == null ) line1 = btrEnt as Line; else line2 = btrEnt as Line; } // if( ell1 != null && ell2 != null && line1 != null && line2 != null ) break; } //foreach( ObjectId entId in btr ) (...) Entity entCurrent = null; Entity entCurrentCloned = null; Point3d p1, p2; if( per.PickedPoint.DistanceTo( ell1Cloned.Center ) < per.PickedPoint.DistanceTo( ell2Cloned.Center ) ) { entCurrent = ell1; entCurrentCloned = ell1Cloned; p1 = ell2Cloned.Center; p2 = ell1Cloned.Center; } //if( per.PickedPoint.DistanceTo( ell1Cloned.Center ) < per.PickedPoint.DistanceTo( ell2Cloned.Center ) ) else { entCurrent = ell2; entCurrentCloned = ell2Cloned; p1 = ell1Cloned.Center; p2 = ell2Cloned.Center; } //else if( per.PickedPoint.DistanceTo( ell1Cloned.Center ) < per.PickedPoint.DistanceTo( ell2Cloned.Center ) ) (...) Matrix3d mat = Matrix3d.Displacement( vecMove ); //Update nearest ellipse entCurrent.UpgradeOpen(); entCurrent.TransformBy( mat ); //Update length of lines Point3d p1Clos = line1.GetClosestPointTo( ell1.Center, true ); Point3d p2Clos = line1.GetClosestPointTo( ell2.Center, true ); line1.UpgradeOpen(); line1.StartPoint = p1Clos; line1.EndPoint = p2Clos; p1Clos = line2.GetClosestPointTo( ell1.Center, true ); p2Clos = line2.GetClosestPointTo( ell2.Center, true ); line2.UpgradeOpen(); line2.StartPoint = p1Clos; line2.EndPoint = p2Clos; blRef.Draw(); tr.Commit(); ed.Regen(); } //using( Transaction tr = doc.TransactionManager.StartTransaction() )
Help please.
Can't find what you're looking for? Ask the community or share your knowledge.