• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual Basic Customization

    Reply
    Active Member
    Posts: 9
    Registered: ‎05-10-2006

    Change Block Attribute Insertion point

    237 Views, 7 Replies
    03-13-2007 04:54 PM
    In need to modify an attributes insertion point in an existing block (ACAD 2002)

    (part code)

    CurrInsrt = attr.InsertionPoint
    insrt(0) = 100 + CurrInsrt(0)
    insrt(1) = 100+ CurrInsrt(1)
    insrt(2) = 0 + CurrInsrt(2)
    attr.InsertionPoint= insrt

    dosen't work and I can't figure out why. CurrInsrt is a variant, insrt is a double(0 to 2)


    I saw the entry about using TextAlignmentPoint but if the attribute is rotated it is rotated around the insertion point not the TextAlignmentPoint

    phill
    Please use plain text.
    Distinguished Contributor
    Posts: 524
    Registered: ‎10-25-2005

    Re: Change Block Attribute Insertion point

    03-13-2007 10:26 PM in reply to: poflynn
    Do it in cad first then code it.
    If you are updating the block, you still have to reinsert all the blockreferences to see the new attribute positions, just like doing it in cad.If you are finding each blockreference and moving the att without updating the block, you better read up on matricies
    Please use plain text.
    Active Member
    Posts: 9
    Registered: ‎05-10-2006

    Re: Change Block Attribute Insertion point

    03-13-2007 11:50 PM in reply to: poflynn
    Yes I am updating it with attr.update.

    But as far as I cantell I am essentially following the example in the help file

    I have tested the other lines and all seems correct.

    "attr.InsertionPoint= insrt
    attr.update"

    is not working and I can't figure out why
    Please use plain text.
    Distinguished Contributor
    Posts: 1,691
    Registered: ‎12-15-2003

    Re: Change Block Attribute Insertion point

    03-14-2007 02:53 PM in reply to: poflynn
    Are you modifying the block definition or each individual block reference. If you are modifying the def only then in AutoCAD try the command ATTSYNC.

    Regards - Nathan
    Please use plain text.
    Active Member
    Posts: 9
    Registered: ‎05-10-2006

    Re: Change Block Attribute Insertion point

    03-14-2007 04:39 PM in reply to: poflynn
    I am actually just trying to change each block reference attribute individually.

    the way I have been doing it is by using the move command to reposition the attribute.

    Is the insertionpoint property a global thing ie applies to the block not the block referenece? that would mean i'd have to sync it for the changes to take affect. In which case I won't use it because the changes will be applied to all blocks

    Phill
    Please use plain text.
    *Expert Elite*
    arcticad
    Posts: 1,250
    Registered: ‎06-21-2004

    Re: Change Block Attribute Insertion point

    03-15-2007 05:00 PM in reply to: poflynn
    I'm sure there is an easier way but this has worked fine for me.

    You just need to set the xyz of the attribute. You do not use move.

    since you can't reference the insertionpoint with att.insertionpoint(0) i just run it through a simple convertion

    dim pt(2) as double
    pt(0) = convertpt(att.insertionpoint,0)
    pt(1) = convertpt(att.insertionpoint,1)
    pt(2) = convertpt(att.insertionpoint,2)

    then you can just add say an x distance to the value or whatever to move the attributes around.

    then assign the new point to your att.insertionpoint

    [code]

    Function convertpt(pt, pos) As Variant
    Dim k As Integer
    Dim newpt(2) As Double
    For Each item In pt
    If j = pos Then
    k = k + 1
    If k = 1 Then
    convertpt = item
    End If
    If k = 2 Then
    convertpt = item
    End If
    If k = 3 Then
    convertpt = item
    End If
    End If
    j = j + 1
    Next

    End Function

    [/code]
    ---------------------------



    “We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
    Please use plain text.
    Active Contributor
    Posts: 28
    Registered: ‎12-29-2006

    Re: Change Block Attribute Insertion point

    03-15-2007 07:55 PM in reply to: poflynn
    Hi Poflynn
    I am not sure but try to regenerate your drawing at end of your code might be it work.
    Thanks
    Please use plain text.
    Distinguished Contributor
    Posts: 524
    Registered: ‎10-25-2005

    Re: Change Block Attribute Insertion point

    03-16-2007 05:49 AM in reply to: poflynn
    Guess I was wrong about matricies for the 2d stuff

    [code]Sub moveatt(B As AcadBlockReference, Dist As Double)

    Dim Att As AcadAttributeReference
    Dim Atts, Pt
    Dim Rot As Double

    Set B = EntSel
    Atts = B.GetAttributes
    Set Att = Atts(0)
    ' Att.LockPosition check that
    Rot = Att.Rotation
    Pt = Att.TextAlignmentPoint
    Pt(0) = Pt(0) + Cos(Rot) * Dist
    Pt(1) = Pt(1) + Sin(Rot) * Dist
    Att.TextAlignmentPoint = Pt

    End Sub
    [/code]
    Please use plain text.