Changing Current Layout and Plot Page Setup Programatically

Changing Current Layout and Plot Page Setup Programatically

Anonymous
Not applicable
3,932 Views
3 Replies
Message 1 of 4

Changing Current Layout and Plot Page Setup Programatically

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
3,933 Views
3 Replies
Replies (3)
Message 2 of 4

fieldguy
Advisor
Advisor
Accepted solution

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 

Message 3 of 4

Anonymous
Not applicable

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!!!

 

0 Likes
Message 4 of 4

fieldguy
Advisor
Advisor

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.