.NET

Reply
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 1 of 4 (493 Views)
Accepted Solution

Changing Current Layout and Plot Page Setup Programatically

493 Views, 3 Replies
07-09-2013 11:05 PM

Hi,

 

After I failed to implement auto-batch-plotting(printing), I decided to do it semi-automatically.

I am going to open each drawing and change the current layout to paperspace1 and set the plot page settings, and then close and save the document.

So now, my problem is chainging current layout of the opened document and manipulating plot page settings.

 

Even a little hint or sample code snippet would be very appreciated. =)

 

FYI, I am currently using Object ARX 2007 with C#.

 

Best regards,

 

Jake

There is plenty of code here for changing layouts.  Try keyword search "layoutname".

 

There is some vb code here http://forums.autodesk.com/t5/NET/Layouts-and-Viewports/td-p/3128748 

Valued Mentor
fieldguy
Posts: 376
Registered: ‎03-31-2005
Message 2 of 4 (473 Views)

Re: Changing Current Layout and Plot Page Setup Programatically

07-10-2013 07:17 AM in reply to: dynamicscope

There is plenty of code here for changing layouts.  Try keyword search "layoutname".

 

There is some vb code here http://forums.autodesk.com/t5/NET/Layouts-and-Viewports/td-p/3128748 

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 3 of 4 (445 Views)

Re: Changing Current Layout and Plot Page Setup Programatically

07-11-2013 05:26 AM in reply to: fieldguy

Awesome~!!

 

Document doc = Application.DocumentManager.Add("acad");
DocumentLock docLock = doc.LockDocument();
Database db = doc.Database;

using (Transaction tr = db.TransactionManager.StartTransaction())
{
	LayoutManager lm = LayoutManager.Current;
	Layout layoutObj;
	DBDictionary layoutDict;

	using (layoutDict = tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary)
	{
		foreach (System.Collections.DictionaryEntry de in layoutDict)
		{
			using (layoutObj = tr.GetObject((ObjectId)(de.Value), OpenMode.ForRead) as Layout)
			{
				lm.CurrentLayout = layoutObj.LayoutName;
			}
		}
	}

	tr.Commit();
}

 

One down!!

 

Now, I need to figure out how to change the page setup programmatically, so I can batch print multiple drawings at once!!!

 

Valued Mentor
fieldguy
Posts: 376
Registered: ‎03-31-2005
Message 4 of 4 (441 Views)

Re: Changing Current Layout and Plot Page Setup Programatically

07-11-2013 07:14 AM in reply to: dynamicscope

Glad you found it.  IMO Kean Walmsley has the best examples for plotting - this is 1 of them

http://through-the-interface.typepad.com/through_the_interface/2007/10/previewing-an-1.html

 

Search plotting at that site for others - they are c# for the most part.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.