.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I wish to insert a title sheet dwg, which has attribute definitions, as a block in another dwg.
I can insert it, and if I explode it, the attribute definitions appear. Otherwise they are not added to the database.
I am using standard code, which I can attach if it helps.
it starts
Dim btr As BlockTableRecord
..
Dim blk As BlockReference = New BlockReference(ip, blkid) ' insert block
..
btr.AppendEntity(blk)
If btr.HasAttributeDefinitions Then
ForEach attID As ObjectId In btr
etc.
but btr.HasAttributeDefinitions = False
Please help?
Solved! Go to Solution.
Re: Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
ps. I have looked everywhere.
Re: Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
you insert a BlockReference into a BlockTableRecord, the the BlockTableRecord will not hold AttributeDefinitions, you have not inserted multiple Objects, just added ONE BlockReference.
And you have no chance to get nested ones.
Try in AutoCAD:
create one Block inluding a rectangle + one Attribute(definition) ==> call it TABLE
copy this Block(References) 5 times
create a new Block(Definition) TABLEGROUP out of these 5 BlockReferences and insert it anywhere in your drawing ==> the BlockReference TABLEGROUP does not show Attribute(References) to work with.
- alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sorry, I don't understand your point.
I am using this code to insert a dwg
Dim btr As BlockTableRecord
Dim bt As BlockTable = DirectCast(tr.GetObject(CurDb.BlockTableId, OpenMode.ForRead), BlockTable)
Dim blkid As ObjectId
If Not bt.Has(Name) Then
btr = tr.GetObject(CurDb.CurrentSpaceId, OpenMode.ForWrite) ' not already inserted?
Dim db As Database = New Database(False, True)
Using db
db.ReadDwgFile(Path, System.IO.FileShare.Read, False, "") ' insert dwg
blkid = CurDb.Insert(Name, db, True)
End Using
End If
btr = DirectCast(tr.GetObject(CurDb.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
If String.IsNullOrEmpty(btr.Name) Then
btr.UpgradeOpen()
btr.Name = Name
btr.DowngradeOpen()
End If
Dim blk As BlockReference = New BlockReference(ip, blkid) ' insert block
I understand that the dwg's attributes may not be loaded into the database. So how do I do that?
Re: Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
could you also attach/upload the drawing that you use for this statement
db.ReadDwgFile(Path, System.IO.FileShare.Read, False, "")
- alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
HI,
ok, I tried ... and I understand your question now ![]()
You donot have a problem defining the BlockDefinition by inserting data from an external DWG
Your problem is: when inserting the BlockReference into the modelspace the AttributeReferences are not generated automatically. And yes, that is by default, to get them inserted look to >>>this sample<<< .... especially the part with:
ar.SetAttributeFromBlock(ad, blkRef.BlockTransform)
The AttRef's have to be created seperatly and attached to the BlockRef's AttributeCollection.
Good luck, - alfred -
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Re: Inserting block with attributes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for that.
I attach a text file showing my code as it seems to encapsulate all that I found out.
