VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block with attribute vba

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
calteq
1471 Views, 3 Replies

Block with attribute vba

Having a problem justifying the text of an attribute created in vb ...

 

here's an simple example ..

 

Sub BlkAttribute()

 

    Dim blockObj As AcadBlock
    Dim insertionPnt(0 To 2) As Double
    Dim txtstyle As AcadTextStyle
    Dim Pnts(0 To 9) As Double
   
    insertionPnt(0) = 0
    insertionPnt(1) = 5
    insertionPnt(2) = 0
   
    Set blockObj = ThisDrawing.Blocks.Add _
                     (insertionPnt, "BlockWithAttribute")
                    
    Pnts(0) = -7.5: Pnts(1) = 5
    Pnts(2) = -7.5: Pnts(3) = 10
    Pnts(4) = 7.5: Pnts(5) = 10
    Pnts(6) = 7.5: Pnts(7) = 5
    Pnts(8) = -7.5: Pnts(9) = 5

    ' Create a lightweight Polyline object in model space
    Set plineObj = blockObj.AddLightWeightPolyline(Pnts)

    ' Add an attribute to the block
    Dim attributeObj As AcadAttribute
    Dim height As Double
    Dim mode As Long
    Dim prompt As String
    Dim insertionPoint(0 To 2) As Double
    Dim tag As String
    Dim value As String
   
    height = 3.5
    mode = acAttributeModeVerify
    prompt = "New Prompt"
   
    insertionPoint(0) = 0
    insertionPoint(1) = 7.5
    insertionPoint(2) = 0
   
    tag = "New Tag"
    value = "New Value"
   
    Set attributeObj = blockObj.AddAttribute(height, mode, _
                          prompt, insertionPoint, tag, value)

 

    'attributeObj.Alignment = acAlignmentBottomCenter
    
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
               (insertionPnt, "BlockWithAttribute", 1#, 1#, 1#, 0)

End Sub

 

the attribute is created with a 'left' justification.

 

when the hi lited part of the code is used the attributes insertion point is changed to 0,0

 

Any suggestions!!!!

 

Regards

Geoff

 

 

 

 

 

 

 

3 REPLIES 3
Message 2 of 4
arcticad
in reply to: calteq

It's a known bug. You will need to move the attributes insertion point back to the known location after you change the justification.

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 4
calteq
in reply to: arcticad

Thx arcticad

 

probably an easy solution for the more knowledgable ....

 

Have trawled thro many web pages to no avail!

 

Have tried this after the alignment statement ....

 

    attributeObj.Move (origin,insertionPoint) .... get 'syntax error'

    attributeObj.Move(origin,insertionPoint)  ... get 'complie error' expected '='

    attributeObj.Move = insertionPoint .....        get 'complie error'   'argument not optional'

 

something I'm not doing correctly ....

 

Hope you don't mind pointing me in the right direction.

 

Geoff

Message 4 of 4
calteq
in reply to: calteq

Thx arcticad

 

I've managed to do it ...

 

        attributeObj.Move Origin, CtrPnt

 

Regards Geoff

 

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

Post to forums  

Autodesk Design & Make Report

”Boost