The Case, I have 2 kinds of blocks in a drawing:
- 1 for revising the the drawing,
- 1 for design information. The block with the designinformation also has the drawingframe attached to it.
The design infoblock contains 1 attribute that needs to be updated when a revision is added in the "revision block". Sometimes a series of these "block couples" are added in modelspace, and they could even be in paperspace. To me this is all very messy and inefficient. But I am not at liberty to change these conditions.
So the question is, how do I go about updating the designblock when a new revision is added in the revisionblock (by VBA)?
- I've noticed that VBA program seems to select the blocks in a random order, so I can't ignore the selection order and suppose all will go well automatically.
- As the above suggests, reading the insertionpoints into a collection doesn't give me the right order of the blocks either. Ordering the "insertionpoints" in the collection seems a bit difficult too. I got this so far, but I got discouraged and stopped (Maybe someone knows how to order these coords? Then that gives me the right blockorder too) :
Code:
Public Sub GetInsPnts()
Dim BlkRef As AcadBlockReference
Dim Layt As AcadLayout
Dim Entities As AcadEntity
Dim RevIns As String
Dim OntIns As String
Dim RevColl As New Collection
Dim OntColl As New Collection
For Each Layt In ThisDrawing.Layouts
For Each Entities In Layt.Block
If TypeOf Entities Is AcadBlockReference Then
Set BlkRef = Entities
If BlkRef.Name Like "Block R*" Then
RevIns = Round(BlkRef.InsertionPoint(0)) & "," & Round(BlkRef.InsertionPoint(1))
RevColl.Add (RevIns)
' perhaps find objects near insertionpoint?
End If
If BlkRef.Name Like "Block D*" Then
OntIns = Round(BlkRef.InsertionPoint(0)) & "," & Round(BlkRef.InsertionPoint(1))
OntColl.Add (OntIns)
End If
End If
Next Entities
Next Layt
End Sub
- I found a lisp routine called VLAX, it looks for the closest point of a polyline to a block. I'm not sure it would work for block to block distances, so I didn't look much further. It seemd more difficult then necessary.
My question is wether anyone has any good ideas on how to approach this efficiently, or wether anyone knows with wich of the above ideas I could best continue. Any help would be great!