Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Highlight the SolidBody that include a Cross Hatch

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ngnam1988
284 Views, 2 Replies

Highlight the SolidBody that include a Cross Hatch

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,

Tags (3)
2 REPLIES 2
Message 2 of 3
Michael.Navara
in reply to: ngnam1988

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
Message 3 of 3
ngnam1988
in reply to: Michael.Navara

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

ngnam1988_0-1708099973869.png

ngnam1988_2-1708100012825.png

Thank you very much!

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report