.NET

Reply
Contributor
ilya.s.solovyev
Posts: 15
Registered: ‎05-01-2012
Message 1 of 9 (309 Views)

Dimensions in viewports with UCS

309 Views, 8 Replies
07-23-2012 12:41 AM

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

ADN Support Specialist
Balaji_Ram
Posts: 749
Registered: ‎03-21-2011
Message 2 of 9 (284 Views)

Re: Dimensions in viewports with UCS

07-26-2012 07:17 AM in reply to: ilya.s.solovyev

Have you tried the "DIMREGEN" ?



Balaji
Developer Technical Services
Autodesk Developer Network

Contributor
ilya.s.solovyev
Posts: 15
Registered: ‎05-01-2012
Message 3 of 9 (281 Views)

Re: Dimensions in viewports with UCS

07-26-2012 07:26 AM in reply to: Balaji_Ram
It didn't help.
ADN Support Specialist
Balaji_Ram
Posts: 749
Registered: ‎03-21-2011
Message 4 of 9 (278 Views)

Re: Dimensions in viewports with UCS

07-26-2012 07:32 AM in reply to: ilya.s.solovyev

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

Contributor
ilya.s.solovyev
Posts: 15
Registered: ‎05-01-2012
Message 5 of 9 (275 Views)

Re: Dimensions in viewports with UCS

07-26-2012 07:43 AM in reply to: ilya.s.solovyev

See attachemnts. Thanks for help.

 

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

ADN Support Specialist
Balaji_Ram
Posts: 749
Registered: ‎03-21-2011
Message 6 of 9 (263 Views)

Re: Dimensions in viewports with UCS

07-27-2012 12:11 PM in reply to: ilya.s.solovyev

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

Contributor
ilya.s.solovyev
Posts: 15
Registered: ‎05-01-2012
Message 7 of 9 (246 Views)

Re: Dimensions in viewports with UCS

07-30-2012 12:33 AM in reply to: Balaji_Ram

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

ADN Support Specialist
Balaji_Ram
Posts: 749
Registered: ‎03-21-2011
Message 8 of 9 (240 Views)

Re: Dimensions in viewports with UCS

07-30-2012 05:21 AM in reply to: ilya.s.solovyev

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

Contributor
ilya.s.solovyev
Posts: 15
Registered: ‎05-01-2012
Message 9 of 9 (236 Views)

Re: Dimensions in viewports with UCS

07-30-2012 07:44 AM in reply to: Balaji_Ram
Yes, I meant exactly what you say. BTW, thanks for help.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.