.NET

Reply
Active Contributor
Chris Ludtke
Posts: 44
Registered: ‎04-12-2005
Message 1 of 10 (116 Views)

Determine Layout of Object

116 Views, 9 Replies
05-27-2005 07:05 AM
I have queried the database and retrieved a selection set of objects (Block References)

I would like to determine if each of these Block References exist in Model space or a layout. I would like to retrieve the layout name.

Can anyone help me.

I have the BlockReference object.
*Albert Szilvasy
Message 2 of 10 (116 Views)

Re: Determine Layout of Object

05-27-2005 08:37 AM in reply to: Chris Ludtke
You go open the BlockTableRecord that the BlockReference referenced and then
query the LayoutId property on the BlockTableRecord. If it is non-null then
you can open it as a Layout and ask for its name.

Albert
wrote in message news:4858659@discussion.autodesk.com...
I have queried the database and retrieved a selection set of objects (Block
References)

I would like to determine if each of these Block References exist in Model
space or a layout. I would like to retrieve the layout name.

Can anyone help me.

I have the BlockReference object.
*Chris Ludtke
Message 3 of 10 (116 Views)

Re: Determine Layout of Object

05-27-2005 09:55 AM in reply to: Chris Ludtke
Thanks Albert,

Another question ...

I have the Layout ID, how do I open it as a layout?

The following does not work

oAcadLayout = CType(oAcadLayoutID, Layout)

"Albert Szilvasy" wrote in message
news:4858822@discussion.autodesk.com...
You go open the BlockTableRecord that the BlockReference referenced and then
query the LayoutId property on the BlockTableRecord. If it is non-null then
you can open it as a Layout and ask for its name.

Albert
wrote in message news:4858659@discussion.autodesk.com...
I have queried the database and retrieved a selection set of objects (Block
References)

I would like to determine if each of these Block References exist in Model
space or a layout. I would like to retrieve the layout name.

Can anyone help me.

I have the BlockReference object.
Contributor
KrishnaK
Posts: 17
Registered: ‎05-24-2005
Message 4 of 10 (116 Views)

Re: Determine Layout of Object

05-27-2005 11:01 AM in reply to: Chris Ludtke
Chris, you need to open the object with its objectID. Check out the AutoCAD.NET labs posted. It will help you understand opening objects in a transaction.
Active Contributor
Chris Ludtke
Posts: 44
Registered: ‎04-12-2005
Message 5 of 10 (116 Views)

Re: Determine Layout of Object

05-27-2005 12:03 PM in reply to: Chris Ludtke
I encourage everyone to download the labs. They helped me a lot.

I am still having problems geting the layout from the Layout ID obtained from the BlockTable Record ...

btrBlockTableRecord = CType(Tr.GetObject(oAcadBlockRef.BlockTableRecord, OpenMode.ForRead, False), BlockTableRecord) ' This works well oAcadBlockRef is a blockreference that I wish to identify, manage and plot

oAcadLayoutID = btrBlockTableRecord.LayoutId() 'This appears to return a valid LayoutID.

oAcadLayout = Tr.GetObject(oAcadLayoutID, OpenMode.ForRead, False, False) ' This does not work. I "morphed" this from examples that I have found in the labs and on the Net.

I am unable to obtain a valid layout object given the objectID.
Contributor
KrishnaK
Posts: 17
Registered: ‎05-24-2005
Message 6 of 10 (116 Views)

Re: Determine Layout of Object

05-27-2005 12:24 PM in reply to: Chris Ludtke
Chris,

AutoCAD only allows you to view "Spaces" i.e., model space or paper spaceXXX. Only these viewable blocktablerecords have an associated layout. You can only plot these. Other blocktablerecords or block definitions that you create, cannot be viewed by itself but only through a block reference inserted in one of the "spaces" (or through a viewport viewing the model).

I hope this made it clear.
Active Contributor
Chris Ludtke
Posts: 44
Registered: ‎04-12-2005
Message 7 of 10 (116 Views)

Re: Determine Layout of Object

05-27-2005 01:56 PM in reply to: Chris Ludtke
I fully understand that I will not be able to plot a BlockTableRecord.

I have identified blocks that are formats that have been placed on one or several layouts.

Thanks to your help, I am able to get attribute information from these formats to determine page number, revision and Drawing Number information.

My problem is different users rename layouts and place these formats in model space, paper space and different layouts. One layout can have 0, 1 or 60 of these Formats.

I have a list of these BlockReferences. I just need to be able to identify what layout they exist in.

How can I get a list of the available "Spaces"?

Armed with a list of available "Spaces", how can I determine whether or not a block reference (by BlockReferenceID) exist in one of these spaces.
Contributor
KrishnaK
Posts: 17
Registered: ‎05-24-2005
Message 8 of 10 (116 Views)

Re: Determine Layout of Object

05-27-2005 02:06 PM in reply to: Chris Ludtke
>>I have a list of these BlockReferences. I just need to be able to identify what layout they exist in.

Get the blockReference's owner using BlockId property. It will be a BlockTableRecord (either a user created block for nested blocks, or one of Model / Paper spaces). Check the layoutId of the BTR. If it is valid, then open it to get the layout.

>>How can I get a list of the available "Spaces"?
Iterate through the block table and see which BTRs have layoutId. Only Model/Paper spaces have a layout assigned.

>>Armed with a list of available "Spaces", how can I determine whether or not a block reference (by BlockReferenceID) exist in one of these spaces.
Check if the block reference's owner matches the BTR id Message was edited by: KrishnaK
Active Contributor
Chris Ludtke
Posts: 44
Registered: ‎04-12-2005
Message 9 of 10 (116 Views)

Re: Determine Layout of Object

05-31-2005 08:20 AM in reply to: Chris Ludtke
Thanks, I am on a roll.

I am getting internal names for the layouts that do not match the names on the "Tabs" shown in the user interface (example, *Paper_space313)

How do go about getting the name of the layout that the user sees?
Contributor
KrishnaK
Posts: 17
Registered: ‎05-24-2005
Message 10 of 10 (116 Views)

Re: Determine Layout of Object

05-31-2005 08:39 AM in reply to: Chris Ludtke
Look for the layout name in the layout dictionary (ACAD_LAYOUT). It is the name user sees. You are wrongly getting the name of the layout from the BTR.

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
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

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

Ask the Community