Ok, I’ll try to explain it:
I have a rectangular dynamic block, which has a hatch associated to it. That block has a stretch action associated with to its length. I’m creating a vba routine which enables me to draw two points and then insert the block between those points with the correct length (which is the distance between those points). Similarly, it can consist on a line and replacing the line with the dynamic block with the correct length. Is basically like having a draw line command but associated with drawing (or inserting) the dynamic block. I have no problem doing that, and it works great. The only problem is that when I ask VBA to modify the length parameter, the hatch doesn’t "join" him; I mean the rectangle stretches to the length that I want, but the hatch stays with its original lengths.
What I’ve figured out is that the hatch does not lose its associativity, but the block becomes un-updated. Because, if a do any action that tells AutoCAD that the block reference must be updated, the hatch acquires its correct length. This is, actions like, stretching it 1 cm more, or changing its visibility state, or opening the block editor and changing something in there, etc. Regen doesn’t do the trick. Ill upload a couple of photos:
-Photo “1a” is the beginning of the command, I’m drawing the lines.
- In Photo “1b” the command is ready and the blocks has been inserted. Hatch is not ok.
- In Photo “1d” I have slightly modified each block on its length and the hatch has accommodate.
Ill include the "Insert block" part of the routine, in case its usefull.
Dim center(0 To 2) As Double
Dim ang As Variant
Dim proy(0 To 1) As Double
Dim WALL As AcadBlockReference
Dim TIPO As String
TIPO = "BloqueMuro2"
Dim atts As Variant
Dim objline As AcadLine
For Each objline In lineSS
Pi = objline.StartPoint
Pj = objline.EndPoint
linelength = objline.Length
center(0) = Pi(0) + (Pj(0) - Pi(0)) / 2
center(1) = Pi(1) + (Pj(1) - Pi(1)) / 2
center(2) = Pi(2) + (Pj(2) - Pi(2)) / 2
proy(0) = Pj(0) - Pi(0)
proy(1) = Pj(1) - Pi(1)
If proy(0) = 0 Then
ang = ThisDrawing.Utility.AngleToReal(90, acDegrees)
Else
ang = Atn(proy(1) / proy(0))
End If
Set WALL = ThisDrawing.ModelSpace.InsertBlock(center, TIPO, 1#, 1#, 1#, ang)
atts = WALL.GetDynamicBlockProperties
For i = LBound(atts) To UBound(atts)
If atts(i).PropertyName = "Longitud" Then
atts(i).Value = objline.Length
End If
Next
Next
WALL.Update
thanks!