.NET

Reply
Distinguished Contributor
Posts: 132
Registered: ‎01-06-2003
Message 1 of 3 (119 Views)

Viewport Layer Freeze Display Issue

119 Views, 2 Replies
01-12-2013 09:09 PM

All,

The following code freezes LayerId in all viewports in all layouts except for LayoutToSkip. This all works well except for the fact that the layers do not correctly display, ie they all remain visible in all viewports. When I check the viewport layer settings they are all correct. If the drawing is saved, closed, and re-opened, then the layers correctly display. As you can see, I have tried vp.UpdateDisplay() and ed.UpdateTiledViewportsFromDatabase() which have no effect. Manually trying regen or regenall does not correct the display. Any thoughts? Thanks, Dale

<code>

// this works, but the display is not correct until dwg is re-opened

publicstatic void LayerFreezeAllViewports(ObjectId pLayerId, string pstrLayoutToSkip)

{

Document doc = AcadApp.DocumentManager.MdiActiveDocument; 

Editored = doc.Editor; 

Databasedb = doc.Database; 

using(Transaction tr = db.TransactionManager.StartTransaction())

{

ObjectId[] ids = new ObjectId[1] { pLayerId }; 

DBDictionary layoutDict = tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary; 

// get current layout

string lstrCurrentLayout = LayoutManager.Current.CurrentLayout; 

foreach(DBDictionaryEntry entry inlayoutDict)

{

if(entry.Key.ToUpper() != "MODEL")

{

Layout lay = tr.GetObject(entry.Value, OpenMode.ForWrite) asLayout; 

// new layouts must be initialised - done at create

//if(lay.LayoutName.ToUpper() != lstrCurrentLayout.ToUpper())

//setCurrentLayoutTab(lay.LayoutName);

// check for layout matching param to leave layers on

if(lay.LayoutName.ToUpper() != pstrLayoutToSkip)

{

foreach(ObjectId vpId inlay.GetViewports())

{

Viewport vp = tr.GetObject(vpId, OpenMode.ForWrite) asViewport;

vp.FreezeLayersInViewport(ids.GetEnumerator());

// DESPERATE TRY

vp.UpdateDisplay();

// ??? save/close/open and all is correct

}}}}

tr.Commit();

}

// ed.UpdateTiledViewportsFromDatabase();

}

<code>

*Expert Elite*
Posts: 1,975
Registered: ‎04-29-2006
Message 2 of 3 (108 Views)

Re : Viewport Layer Freeze Display Issue

01-13-2013 02:00 AM in reply to: Dale.Bartlett

Hi,

 

IMHO, this is not due to your code but to the current value of LAYOUTREGENCTRL while switching between tabs after you run your code.

Gilles Chanteau
Distinguished Contributor
Posts: 132
Registered: ‎01-06-2003
Message 3 of 3 (86 Views)

Re: Viewport Layer Freeze Display Issue

01-13-2013 11:00 PM in reply to: Dale.Bartlett

Thanks, I'll try that.

Regards, Dale

nb LAYOUTREGENCTL (not CTRL)

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
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

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

Ask the Community