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

Assign plotstyle to Attribute definition in block

1 REPLY 1
Reply
Message 1 of 2
Dollih
317 Views, 1 Reply

Assign plotstyle to Attribute definition in block

Hi.

 

I am trying to assign a plotstyle to attribute while creating a block.
First I create the block, then I insert the Blockref, in that process I have errors assigining a plotstyle to the attribute.
(I have also tried to assign the plotstyle while creating the block and attribute with poor results.)

Here is my attempt to do this:

 

            For Each objId As ObjectId In blkTblR
                Dim obj As DBObject = objId.GetObject(OpenMode.ForRead)
                If TypeOf obj Is AttributeDefinition Then
                    Dim ad As AttributeDefinition = objId.GetObject(OpenMode.ForRead)
                    Dim ar As AttributeReference = New AttributeReference()
                    ar.SetAttributeFromBlock(ad, blkRef.BlockTransform)
                    ar.Position = ad.Position.TransformBy(blkRef.BlockTransform)

                    ar.PlotStyleName = "025"

                    blkRef.AttributeCollection.AppendAttribute(ar)
                    tr.AddNewlyCreatedDBObject(ar, True)
                End If
            Next

 

Best wishes,

 

 

1 REPLY 1
Message 2 of 2
CallMeJames
in reply to: Dollih

Without seeing the rest of the code and just off the top of my head, I don't see a transaction and you are only opening the attribute definition for read, not write.

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