Dimensions in viewports with UCS

Dimensions in viewports with UCS

Anonymous
Not applicable
1,999 Views
8 Replies
Message 1 of 9

Dimensions in viewports with UCS

Anonymous
Not applicable

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

0 Likes
2,000 Views
8 Replies
Replies (8)
Message 2 of 9

Balaji_Ram
Alumni
Alumni

Have you tried the "DIMREGEN" ?



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 9

Anonymous
Not applicable
It didn't help.
0 Likes
Message 4 of 9

Balaji_Ram
Alumni
Alumni

If you can provide a sample buildable sample project to reproduce the behavior, I can take a look at it.



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 9

Anonymous
Not applicable

See attachemnts. Thanks for help.

 

The problem is to make dimension in viewport "look readable" (programmatically or by command).

0 Likes
Message 6 of 9

Balaji_Ram
Alumni
Alumni

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();
	}
}

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 9

Anonymous
Not applicable

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".

0 Likes
Message 8 of 9

Balaji_Ram
Alumni
Alumni

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.

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 9 of 9

Anonymous
Not applicable
Yes, I meant exactly what you say. BTW, thanks for help.
0 Likes