Determine Layout of Object

Determine Layout of Object

Anonymous
Not applicable
1,145 Views
9 Replies
Message 1 of 10

Determine Layout of Object

Anonymous
Not applicable
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.
0 Likes
1,146 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
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.
0 Likes
Message 3 of 10

Anonymous
Not applicable
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.
0 Likes
Message 4 of 10

KrishnaK
Archived Account
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.
0 Likes
Message 5 of 10

Anonymous
Not applicable
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.
0 Likes
Message 6 of 10

KrishnaK
Archived Account
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.
0 Likes
Message 7 of 10

Anonymous
Not applicable
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.
0 Likes
Message 8 of 10

KrishnaK
Archived Account
>>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
0 Likes
Message 9 of 10

Anonymous
Not applicable
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?
0 Likes
Message 10 of 10

KrishnaK
Archived Account
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.
0 Likes