Force update of associative hatch

Force update of associative hatch

Anonymous
Not applicable
4,630 Views
11 Replies
Message 1 of 12

Force update of associative hatch

Anonymous
Not applicable

Hi all,

we have some drawings where associative hatches do not follow their boundaries. I don't know were the problem comes from precisely. It might be caused by the use of BULKRHB as per "http://gistncase.blogspot.be/2012/04/autocad-recreate-closed-boundaries-for.html", but I'm really not sure of this.

Moving any point of the boundary makes the hatch OK again.

 

Anyway we are looking for a way to solve this. Is there a way to force the hatches te be redrawn as per their boudaries ?

REGENing the drawing does not help.

I tried a small visual-lisp routine to call vla-Evaluate on every hatch object, but that has no apparent effect.

 

The only solution I have found is to select all boundaries and move them in some direction then back in another to force the hatch to be redrawn.

Very inefficient (I would like to do this in accaddoc.lsp to avoid any problem, and moving a lot of boundaries twice can be very slow), and inellegant.

 

Thanks a lot for your help !

 

 

PS : using AcadMap 3D 2009

0 Likes
4,631 Views
11 Replies
Replies (11)
Message 2 of 12

pendean
Community Legend
Community Legend
REGEN or REGENALL commands not do it?
0 Likes
Message 3 of 12

Anonymous
Not applicable
No, REGEN does not help (REGENALL neither).
0 Likes
Message 4 of 12

Anonymous
Not applicable
Some update on this : if I close the drawing with the either the layer containing the boundaries or the layer containing the hatches frozen, the problem stays, and I have a bunch of messages in the command when the drawing opens. Basically translated from French, either "Boundary entity on frozen or locked layer. Associative hatches not updated" or "Associative hatches on frozen or locked layer, no update".
If I thaw all layers, close and save then reopen, the hatches are fine !
So there is something that Autocad does when it first opens the drawing that solves the problem (i.e. it force-updates the hatches to follow the boundaries). I would really like to find a way to replicate this manually ! Is this possible ? Thanks !
0 Likes
Message 5 of 12

Anonymous
Not applicable

OK, two new information this problem :

 

First, it happens only when I manipulate the drawing via VBA. Here is a description of the workflow :

- A VBA procedure opens and closes drawing from a list. I launch this procedure with no dawing opened in AutoCad, and just open them one at a time with "Set oDrawing = Application.Documents.Add(path)", and then close them with "oDrawing.Close True" (i.e. saving changes).

- Upon opening the drawing, lisp routines contained in the S::STARTUP function of my acaddoc.lsp files are run. One of them is a "Recreate Hatch Boundary" routine, inspired by this article.

When I do this, some hatches get corrupted (i.e. they do not follow their boundaries anymore).

If i do the same thing manually, everything is fine : I open the drawing and close/save it, but not via VBA, manualle via the file open dialog.

So there is some problem when everything happens in VBA, and I don't know what.

 

Second, I know how to reproduce the problem by hand. Just create an associative hatch, put the boundary on another layer, freeze de hatch layer, edit the boundary (you get a message about associative hatch not updated because on frozen or locked layer), thaw the hatch layer : hatch does not follow boundary anymore. I can regenall or do anything, nothing works. If I edit the boundary, the hatch is updated just fine. If I close and save the drawing and reopen it, the hatch is also updated during the opening process (I can see it is wrong when the drawing opens, then some magic happens and it is updated before the end of the opening process).

 

So I have two ways to solve this : either find what's different when opening/closing/saving drawings in VBA, or find a way to reproduce Autocad's "regen upon open" behaviour.

Also note that re-opening the drawing via VBA does not work, the drawing is not correctly regenerated.

 

0 Likes
Message 6 of 12

alprock
Explorer
Explorer

Actually reopening dwg file from vba and running regenall command works for me!

 

Sub ReloadAndRegen()

ThisDrawing.SaveAs "test.dwg"
ThisDrawing.Close
AcadApplication.Documents.Open "test.dwg"
ThisDrawing.Regen all

End Sub

 

I've tested this in Autocad 2019 and it works for me, hope it'll help.

0 Likes
Message 7 of 12

Anonymous
Not applicable

Thanks for the update, but I already mentionned this in my message :

 

If I close and save the drawing and reopen it, the hatch is also updated during the opening process

 

The problem is that I cannot do this because I have some VBA code that queries hatches objects upon saving, so the hatches have to be already OK at that specific moment.

 

 

0 Likes
Message 8 of 12

Anonymous
Not applicable

Did you ever find a solution to this? Having a similar problem. Not working in VBA but trying to find a way to force associative hatches within multiple instances of dynamic blocks to 'rebuild'.

0 Likes
Message 9 of 12

Anonymous
Not applicable

No, sorry. The only solution is to prevent edition of boundaries  when the hatch layer is frozen.

I haven't found a way to force the hatch to update after a boundary edition.

0 Likes
Message 10 of 12

g_spoerer
Explorer
Explorer

Hi, have yuo found the way to solve this problem? Im with the same issue right now, any ideas would be very helpfull..

0 Likes
Message 11 of 12

cadffm
Consultant
Consultant

- Use proper programmed Tools

-Read what Adesk tell you

-Set up Pickstyle for associated hatch

 

So: What do you looking for other than this?

What causes the problem in your case?

 

You told nothing about your situation(The Q what creates the problem)

Sebastian

0 Likes
Message 12 of 12

g_spoerer
Explorer
Explorer

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!

0 Likes