.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dimensions in viewports with UCS

8 REPLIES 8
Reply
Message 1 of 9
ilya.s.solovyev
927 Views, 8 Replies

Dimensions in viewports with UCS

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

8 REPLIES 8
Message 2 of 9

Have you tried the "DIMREGEN" ?



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 9

It didn't help.
Message 4 of 9

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

Message 5 of 9

See attachemnts. Thanks for help.

 

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

Message 6 of 9

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

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

Message 8 of 9

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

Message 9 of 9

Yes, I meant exactly what you say. BTW, thanks for help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost