I have some aligned dimensions in model space - they look ok, text is oriented according to WCS. Also I have some viewports with UCS (I used commands UCS, PLAN) where dimensions look wrong, text is not oriented correctly. Is it possible to "update" dimension in viewport to orient text as in model space?
Programmatically created dims in viewports oriented as in model space, not considering current UCS.
* I duplicated this post at AutoCAD General Forum
Have you tried the "DIMREGEN" ?
If you can provide a sample buildable sample project to reproduce the behavior, I can take a look at it.
See attachemnts. Thanks for help.
The problem is to make dimension in viewport "look readable" (programmatically or by command).
Hi ilya,
By "look readable", do you mean the Paperspace viewport displays the dimension the same way as displayed in the modelspace ?
If so, here is a sample code with minimal error checking to set the view of the selected paperspace viewport based on the view settings of the "*Active" view table record (Model space view settings).
[CommandMethod("UpdateVP", CommandFlags.NoTileMode)] static public void UpdateVPMethod() { Document activeDoc = Application.DocumentManager.MdiActiveDocument; Database db = activeDoc.Database; Editor ed = activeDoc.Editor; PromptEntityOptions peo = new PromptEntityOptions("Select a viewport : "); peo.SetRejectMessage("Select a viewport."); peo.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Viewport), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) { ed.WriteMessage("Nothing selected. Please run the command again."); return; } ObjectId oid = per.ObjectId; using (Transaction tr = db.TransactionManager.StartTransaction()) { ViewportTable vt = tr.GetObject(db.ViewportTableId, OpenMode.ForRead) as ViewportTable; ViewportTableRecord vtr = tr.GetObject(vt["*Active"], OpenMode.ForWrite) as ViewportTableRecord; Autodesk.AutoCAD.DatabaseServices.Viewport vp = tr.GetObject(oid, OpenMode.ForWrite) as Autodesk.AutoCAD.DatabaseServices.Viewport; if (vtr != null && vp != null) { vp.ViewHeight = vtr.Height; vp.ViewTarget = vtr.Target; vp.ViewDirection = vtr.ViewDirection; vp.TwistAngle = vtr.ViewTwist; vp.ViewCenter = vtr.CenterPoint; } tr.Commit(); } }
Your code changes viewport UCS - it is not acceptable. The thing is viewports must have their own UCS and must display dimensions in "readable" form (like when you create new dim in viewport with UCS).
Of course, two completely different viewports cannot display "readable" dims at one moment. That is why I have to create a command (instument) to orient dim in current viewport to make in "readable".
Do you mean changing the orientation of the dimension to make it "readable" without changing the view parameters of the Viewport ?
In that case, I dont have a ready sample code for that, but I suggest you should look at performing a transformation of the dimension using the "Entity.TransformBy" method.
Can't find what you're looking for? Ask the community or share your knowledge.