Author Topic: Transients and TILEMODE=0  (Read 2890 times)

0 Members and 1 Guest are viewing this topic.

kaefer

  • Guest
Transients and TILEMODE=0
« on: January 06, 2011, 02:55:03 PM »
Hi friends,

what is the story with those ghosts? Those four red crosses near the origin are intentional, the other four below the crosshairs are not. The offending line
Code: [Select]
Autodesk.AutoCAD.GraphicsInterface.TransientManager.CurrentTransientManager.AddTransient(
    ent,
    Autodesk.AutoCAD.GraphicsInterface.TransientDrawingMode.DirectShortTerm,
    128, new IntegerCollection() )
is called in a loop for each line of the little red crosses once and draws them in every viewport.

Now I do know that one wouldn't and shouldn't work in modelspace through a viewport, and think full coverage of tiled viewports is a good thing.  Having this too in the paperspace viewport I find still irritating; I don't think there's a way around it.

Thorsten


kaefer

  • Guest
Re: Transients and TILEMODE=0
« Reply #1 on: January 17, 2011, 03:03:47 PM »
Now I do know that one wouldn't and shouldn't work in modelspace through a viewport, and think full coverage of tiled viewports is a good thing.  Having this too in the paperspace viewport I find still irritating; I don't think there's a way around it.

Of course there's a way around it! That's what the last parameter of Autodesk.AutoCAD.GraphicsInterface.TransientManager.AddTransient is for:
an IntegerCollection for the passing of viewport numbers. Example in F#:

Code: [Select]
   let viewports = new IntegerCollection()

    let setViewports() =
        let db = acApp.DocumentManager.MdiActiveDocument.Database
        let tilemode =  
            acApp.GetSystemVariable "TILEMODE" |> unbox<int16> = 1s
        let inPaperspace =
            acApp.GetSystemVariable "CVPORT" |> unbox<int16> = 1s
        // do nothing when in modelspace
        if tilemode then ()
        // paperspace viewport only when in paperspace
        elif inPaperspace then viewports.Add 1 |> ignore
        // add all except paperspace viewport when floating
        else
            use tr = db.TransactionManager.StartTransaction()
            for vpId in db.GetViewports false do
                let vp = tr.GetObject(vpId, OpenMode.ForRead) :?> Viewport
                viewports.Add vp.Number |> ignore
            tr.Commit()

The idea is to generate the viewport numbers only when really necessary; that is in a floating viewport; the other cases are trivial. I hope they make sense: all viewports (default) when in modelspace, paperspace viewport only when in paperspace.

All the best, Thorsten

PS Do you read me, Norman?

PPS [Edited] Nice try. CVPORT = 1 for paperspace is right.
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide, Define Layouts and Plot > Viewports > Floating Viewports is wrong.
« Last Edit: January 17, 2011, 05:42:26 PM by kaefer »