Boundary of a non-associative hatch?

Boundary of a non-associative hatch?

Anonymous
Not applicable
614 Views
2 Replies
Message 1 of 3

Boundary of a non-associative hatch?

Anonymous
Not applicable
Is this a contradiction in terms? I tried the 'GetLoop' method on a non-associative hatch, and the variant returned EMPTY. Im hoping that there is a way to get its outer boundary, because a bounding box would not always reflect the hatches true shape.

What Im trying to do here is, find non-associative hatches in a drawing, and replace them with associatve ones. The geometrythe hatch was created with is still there, so once I find the hatch, I can match it up to the nearby geometry, and then create a new, associative one, match its properties, and delete the old one.

or am I going about this in the wrong fashion?
0 Likes
615 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
You need to know how many loops are in a hatch first by using
integer = hatchObj.NumberOfLoops
and then you can look in each loop (array of acceptable objects) by using
hatchObj.GetLoopAt 0, variantVariable
You can then cycle through the objects to determine geometry, which each method may be specific to object type. I don't recall determining the inner or outer loops, may have something to do with the "normal" property? Don't recall.

The following code may be helpful, this makes hatches:

Sub testIt()
Dim selSet As AcadSelectionSet, newHatch As AcadHatch
Dim foutLoops() As AcadEntity, finLoops() As AcadEntity
ThisDrawing.Utility.Prompt "Please select outer loops to form the hatch:"
Set selSet = clnSSet
For i = 0 To selSet.Count - 1
ReDim Preserve foutLoops(i)
Set foutLoops(i) = selSet(i)
Next i
ThisDrawing.Utility.Prompt "Please select inner loops to be subtracted from hatch:"
Set selSet = clnSSet
For i = 0 To selSet.Count - 1
ReDim Preserve finLoops(i)
Set finLoops(i) = selSet(i)
Next i
Set newHatch = mkHatch("ANSI32", foutLoops, finLoops)
End Sub

Function mkHatch(patName As String, oLoopObjs As Variant, _
iLoopObjs As Variant, Optional layrName As String = "") As AcadHatch
Dim i As Integer, olObjs(0) As AcadEntity, fHatch As AcadHatch
j = -1
Set fHatch = ThisDrawing.ModelSpace.AddHatch(acHatchPatternTypePreDefined, patName, False)
On Error Resume Next
For i = LBound(oLoopObjs) To UBound(oLoopObjs)
Set olObjs(0) = oLoopObjs(i)
fHatch.AppendOuterLoop (olObjs)
fHatch.Evaluate
Next i
For i = LBound(iLoopObjs) To UBound(iLoopObjs)
Set olObjs(0) = iLoopObjs(i)
fHatch.AppendOuterLoop (olObjs)
fHatch.Evaluate
Next i
On Error GoTo 0
If layrName <> "" Then fHatch.Layer = layrName
Set mkHatch = fHatch
Set fHatch = Nothing
End Function

Function clnSSet() As AcadSelectionSet
Dim fType(0 To 8) As Integer
Dim fData(0 To 8) As Variant
On Error Resume Next
If ThisDrawing.SelectionSets("SSdtlCat") Is Nothing Then
Set clnSSet = ThisDrawing.SelectionSets.Add("SSdtlCat")
Else
Set clnSSet = ThisDrawing.SelectionSets("SSdtlCat")
clnSSet.Clear
End If
On Error GoTo 0
clnSSet.SelectOnScreen
End Function
0 Likes
Message 3 of 3

Anonymous
Not applicable
If its non-associative, no you cannot. The only way I was able to do this was by outputting the hatch in a DXF and reading the DXF file and recreating the components of the boundary.

Look at this bit that I done 2 years ago. It sould help you:
http://discussion.autodesk.com/thread.jspa?messageID=5062337

Everythig you need to recreate boundaries is in this forums (some guy in this post has got it to work, so read it all, and you should be able to do it.)

Hope this helps.
0 Likes