.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Determine Layout of Object

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
565 Views, 9 Replies

Determine Layout of Object

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.
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

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.
Message 3 of 10
Anonymous
in reply to: Anonymous

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.
Message 4 of 10
KrishnaK
in reply to: Anonymous

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.
Message 5 of 10
Anonymous
in reply to: Anonymous

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.
Message 6 of 10
KrishnaK
in reply to: Anonymous

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.
Message 7 of 10
Anonymous
in reply to: Anonymous

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.
Message 8 of 10
KrishnaK
in reply to: Anonymous

>>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
Message 9 of 10
Anonymous
in reply to: Anonymous

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?
Message 10 of 10
KrishnaK
in reply to: Anonymous

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost