.NET

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

Dimensions in viewports with UCS

255 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: 669
Registered: ‎03-21-2011
Message 2 of 9 (230 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 (227 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: 669
Registered: ‎03-21-2011
Message 4 of 9 (224 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 (221 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: 669
Registered: ‎03-21-2011
Message 6 of 9 (209 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 (192 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: 669
Registered: ‎03-21-2011
Message 8 of 9 (186 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 (182 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community