I have copied in objects from another drawing into my drawing and then used the following code to look at line angles based on user selection.
[CommandMethod("AddPlObjEvent", CommandFlags.Session)] public void AddPlObjEvent() { var doc = app.DocumentManager.MdiActiveDocument; var ed = doc.Editor; Database db = doc.Database; Vector3d mat = ed.CurrentUserCoordinateSystem.Translation; using (var ads = doc.LockDocument()) { var pPtRes = doc.Editor.GetEntity("Select an object"); using (Transaction acTrans = db.TransactionManager.StartTransaction()) { // Open the Block table record for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // Open the active viewport ViewportTableRecord acVportTblRec; acVportTblRec = acTrans.GetObject(doc.Editor.ActiveViewportId, OpenMode.ForWrite) as ViewportTableRecord; Line exampeLine = acTrans.GetObject(pPtRes.ObjectId, OpenMode.ForWrite) as Line; ed.WriteMessage("\nLine Angle is:" + Place_Cables.Nearby_Cables.radToDeg(exampeLine.Angle)); } } }
It returns the wrong angles; the image below shows the angles I expect and see in properties and then in the red box the angles my code returns. I think it has something to do with UCS to WCS but I am unsure on how to get the copied objects ordinate system. If I draw a new line then I get the angles not in the red box. I would like to either:
-use the copied ordinate system to convert my new line angles to the copied objects ordinates
-convert all copied objects to my ordinate system.
Solved! Go to Solution.
I have copied in objects from another drawing into my drawing and then used the following code to look at line angles based on user selection.
[CommandMethod("AddPlObjEvent", CommandFlags.Session)] public void AddPlObjEvent() { var doc = app.DocumentManager.MdiActiveDocument; var ed = doc.Editor; Database db = doc.Database; Vector3d mat = ed.CurrentUserCoordinateSystem.Translation; using (var ads = doc.LockDocument()) { var pPtRes = doc.Editor.GetEntity("Select an object"); using (Transaction acTrans = db.TransactionManager.StartTransaction()) { // Open the Block table record for read BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; // Open the Block table record Model space for write BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // Open the active viewport ViewportTableRecord acVportTblRec; acVportTblRec = acTrans.GetObject(doc.Editor.ActiveViewportId, OpenMode.ForWrite) as ViewportTableRecord; Line exampeLine = acTrans.GetObject(pPtRes.ObjectId, OpenMode.ForWrite) as Line; ed.WriteMessage("\nLine Angle is:" + Place_Cables.Nearby_Cables.radToDeg(exampeLine.Angle)); } } }
It returns the wrong angles; the image below shows the angles I expect and see in properties and then in the red box the angles my code returns. I think it has something to do with UCS to WCS but I am unsure on how to get the copied objects ordinate system. If I draw a new line then I get the angles not in the red box. I would like to either:
-use the copied ordinate system to convert my new line angles to the copied objects ordinates
-convert all copied objects to my ordinate system.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Hi,
Line.Angle always returns the angle in radians measured counterclockwise from WCS X axis.
if you want to reflect the current angular units and the ANGDIR and ANGBASE settings as does the property palette, just use the Converter.AngletoSring method.
ed.WriteMessage("\nLine Angle is: " + Converter.AngleToString(exampeLine.Angle));
Hi,
Line.Angle always returns the angle in radians measured counterclockwise from WCS X axis.
if you want to reflect the current angular units and the ANGDIR and ANGBASE settings as does the property palette, just use the Converter.AngletoSring method.
ed.WriteMessage("\nLine Angle is: " + Converter.AngleToString(exampeLine.Angle));
I am not sure how the forums would get along without you gile
I am not sure how the forums would get along without you gile
Can't find what you're looking for? Ask the community or share your knowledge.