.NET

Reply
Valued Contributor
65 Posts
1 Kudo
Registered: ‎07-23-2008
Post 1 of 4
Accepted Solution

Change the current space

249 Views, 3 Replies
07-11-2011 04:01 PM

Hello everybody,

 

I have a small application that zooms on an entity with specific properties. The problem is that if I am in paperspace and the entity is in model space, i cannot see the entity. How can I make the entity's space to become the current space?

 

Thanks,

 

e.g.

If you know the name of the layout you can use

 

LayoutManager.Current.CurrentLayout = layoutName

 

If you don't know the layout of the entity you can use:

 

    Public Shared Function GetLayoutName(ByVal ent As Entity) As String
        Dim blockId As ObjectId = ent.BlockId
        Dim btr As BlockTableRecord = TryCast(ent.BlockId.GetObject(OpenMode.ForRead), BlockTableRecord)
        If Not btr.LayoutId.IsNull Then
            Dim layout As Layout = TryCast(btr.LayoutId.GetObject(OpenMode.ForRead), Layout)
            Return layout.LayoutName
        End If
        Return String.Empty
    End Function

*Expert Elite*
2,142 Posts
255 Kudos
Registered: ‎04-29-2006
Post 2 of 4

Re : Change the current space

07-12-2011 01:01 AM in reply to: e.g.

Hi,

 

You can use the read/write CTAB sysvar.

Gilles Chanteau
Distinguished Mentor
607 Posts
37 Kudos
Registered: ‎03-18-2008
Post 3 of 4

Re: Change the current space

07-12-2011 07:49 AM in reply to: e.g.

If you know the name of the layout you can use

 

LayoutManager.Current.CurrentLayout = layoutName

 

If you don't know the layout of the entity you can use:

 

    Public Shared Function GetLayoutName(ByVal ent As Entity) As String
        Dim blockId As ObjectId = ent.BlockId
        Dim btr As BlockTableRecord = TryCast(ent.BlockId.GetObject(OpenMode.ForRead), BlockTableRecord)
        If Not btr.LayoutId.IsNull Then
            Dim layout As Layout = TryCast(btr.LayoutId.GetObject(OpenMode.ForRead), Layout)
            Return layout.LayoutName
        End If
        Return String.Empty
    End Function

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer
Valued Contributor
65 Posts
1 Kudo
Registered: ‎07-23-2008
Post 4 of 4

Re: Change the current space

07-12-2011 10:13 AM in reply to: michael.robertson

Thank you very much, it did help.

 

e.g.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
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!