Highlight the SolidBody that include a Cross Hatch

ngnam1988
Advocate
Advocate

Highlight the SolidBody that include a Cross Hatch

ngnam1988
Advocate
Advocate

Dears,

I'm trying working with DrawingViewHatchRegion to return the SolidBody.

ngnam1988_0-1708071440097.png

 

Could you help me how to highlight the body that include a cross hatch. I'm working with these code:

Sub Main()
	Dim _InventorApp As Application = ThisApplication
	Dim oDOC As DrawingDocument = _InventorApp.ActiveDocument
	Dim oSelectSet As SelectSet = oDOC.SelectSet
	oSelectSet.Clear()
	Dim oView As DrawingView = _InventorApp.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View to Edit.")
	If oView Is Nothing Then Exit Sub
	If oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType Then
		Dim oSecView As SectionDrawingView = oView
		If oSecView.HatchRegions.Count() > 0 Then
			For Each oHR As DrawingViewHatchRegion In oSecView.HatchRegions
				Dim oSB As SurfaceBody = oHR.SurfaceBody
				MsgBox(oSB.Name)

				'NEED CODE THAT CAN HIGHLIGHT EACH BODY HAS GOT HATCH REGION
				oSelectSet.Select(oSB) 'NOT WORKING....

			Next
		End If
	End If
End Sub

 Thanks,

0 Likes
Reply
Accepted solutions (1)
305 Views
2 Replies
Replies (2)

Michael.Navara
Advisor
Advisor
Accepted solution

You need to select DrawingCurveSegments in drawing view. Try this code modification

Sub Main
	Dim _InventorApp As Application = ThisApplication
	Dim oDOC As DrawingDocument = _InventorApp.ActiveDocument
	Dim oSelectSet As SelectSet = oDOC.SelectSet
	oSelectSet.Clear()
	Dim oView As DrawingView = _InventorApp.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View to Edit.")
	If oView Is Nothing Then Exit Sub
	If oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType Then
		Dim oSecView As SectionDrawingView = oView
		If oSecView.HatchRegions.Count() > 0 Then
			For Each oHR As DrawingViewHatchRegion In oSecView.HatchRegions
				Dim oSB As SurfaceBody = oHR.SurfaceBody
				MsgBox(oSB.Name)

				'NEED CODE THAT CAN HIGHLIGHT EACH BODY HAS GOT HATCH REGION
				'oSelectSet.Select(oSB) 'NOT WORKING....
				Dim coll As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
				For Each curve As DrawingCurve In oView.DrawingCurves(oSB)
					For Each seg As DrawingCurveSegment In curve.Segments
						coll.Add(seg)
					Next
				Next
				oSelectSet.SelectMultiple(coll)

			Next
		End If
	End If
End Sub

ngnam1988
Advocate
Advocate

Thanks! @Michael.Navara 
I got it. You're super!

ngnam1988_0-1708099973869.png

ngnam1988_2-1708100012825.png

Thank you very much!

 

0 Likes