Jump to content

Update multi-line attributes


Oga87

Recommended Posts

Hello Dear AutoCAD specialists!

The code below “excel-vba” allows you to update attribute values. The problem is that if this attribute is “multiline”, such properties as, for example, compression are reset: it was 0,8 - after updating -1. (as well as slope, etc.).
Could you please tell me how to fix the code so that after updating multiline attributes, such properties are preserved?

n_at = 0
varAttributes = blockObj.GetAttributes

    For r_a_n = 8 To Col_N1
    For n_at = LBound(varAttributes) To UBound(varAttributes)
    If varAttributes(n_at).TagString = Cells(6, r_a_n).Value Then varAttributes(n_at).TextString = ActiveCell.Offset(0, r_a_n - 6).Value
     Next n_at
     Next r_a_n

 

Link to comment
Share on other sites

You may need to look at the textstring sometimes it can be Line1line2 or it can be line1\\Pline2 or maybe Line1\nline2 when replacing the string, need the add a line break, Sorry dont do VBA just dabble at edges. 

Link to comment
Share on other sites

Any reason your not doing this from AutoCAD? Plenty of LISP, VBA, etc. out there for that already, though I never really dabbled with altering Multiline Attributes.

 

From what I see, Multiline Attributes have to be handled different than Single Line Attributes.

 

Start with this, I will look more when I can spare some time at work. Let me know if this is getting closer.

 

varAttributes = blockObj.GetAttributes
    

    For r_a_n = 8 To Col_N1
        For n_at = LBound(varAttributes) To UBound(varAttributes)
            tagName = Cells(6, r_a_n).Value
            newValue = ActiveCell.Offset(0, r_a_n - 6).Value
            

            If varAttributes(n_at).TagString = tagName Then
                varAttributes(n_at).TextString = newValue
                

                If varAttributes(n_at).TextString <> newValue Then
                    varAttributes(n_at).TextString = newValue
                End If
            End If
        Next n_at
    Next r_a_n

 

You might also check out this post...

 

steven-g probably has some more code around, he mostly used LT and used Excel a lot to handle AutoCAD LT.

Link to comment
Share on other sites

Thanks, this code also resets the specified compression.
Perhaps the compression should be remembered (as a property) and then returned.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...