Active Contributor
42 Posts
0 Kudos
Registered: ‎08-11-2011
Post 1 of 4

CHSPACE in Viewport programmatically?

299 Views, 3 Replies
08-13-2013 04:26 AM

Need to get inside the viewport in paperspace and run the command CHSPACE to bring some layers to the modelspace viewport. How to do this programmatically?

principle is as follows:

[CommandMethod("ChangeViewports")] public static void ChangeViewports() { Document document = Application.DocumentManager.MdiActiveDocument; Database database = document.Database; Editor editor = document.Editor; using (Transaction transaction = database.TransactionManager.StartTransaction()) { ObjectIdCollection objectIdCollection = database.GetViewports(false); foreach (ObjectId id in objectIdCollection) { Viewport viewport = transaction.GetObject(id, OpenMode.ForWrite) as Viewport; if (viewport.StandardScale == StandardScaleType.Scale1To1) viewport.Erase(); else { //Run this command CHSPACE viewport } } transaction.Commit(); } }





Thank you!

ADN Support Specialist
687 Posts
80 Kudos
Registered: ‎06-02-2009
Post 2 of 4

Re: CHSPACE in Viewport programmatically?

09-11-2013 01:36 AM in reply to: NayaraFJ



You can run a command using Document.SendStringToExecute. However I don't really understand the point of your question as same layers exist in both model and paper spaces, I don't see how you're going to use CHSPACE to import a layer from model to paper, this command only applies to entities...









Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Active Contributor
37 Posts
4 Kudos
Registered: ‎11-13-2006
Post 3 of 4

Re: CHSPACE in Viewport programmatically?

09-12-2013 05:52 PM in reply to: NayaraFJ

Is this what you are after?

Selecting Model Space entities from Paper Space


matt worland
188 Posts
11 Kudos
Registered: ‎01-06-2003
Post 4 of 4

Re: CHSPACE in Viewport programmatically?

11-13-2013 02:06 AM in reply to: matt.worland
I need the same. I think he means copy objects (not just layers) from MS to PS. My need is to copy a selected closed polyline from MS to PS, suitably scaled to match the VP. [Selecting Model Space entities from Paper Space] just creates a selection set based on the viewport window. Not quite the same. Dale

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!