Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: hieut1392

Hi @hieut1392.  This is a relatively common request, but as usual, much more difficult to do by code than it is to do manually.  If you search within this forum, you will likely find several similar discussions very similar to this one.  Below is a link to another similar one I just replied to today:

https://forums.autodesk.com/t5/inventor-programming-ilogic/hide-all-drawing-hidden-lines-that-aren-t... 

 

Below is an example iLogic rule you can test with, to see if it works the way you want it to.

Sub Main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oDDoc As DrawingDocument = TryCast(oInvApp.ActiveDocument, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Return
	Dim oView As DrawingView = oInvApp.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a Drawing View.")
	If oView Is Nothing Then Return
	Dim oViewDoc As Inventor.Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
	If (oViewDoc Is Nothing) OrElse (Not TypeOf oViewDoc Is PartDocument) Then Return
	Dim oViewPDoc As PartDocument = oViewDoc
	Dim oBodies As SurfaceBodies = oViewPDoc.ComponentDefinition.SurfaceBodies
	Dim oBodyNames As New List(Of String)
	For Each oBody As SurfaceBody In oBodies
		oBodyNames.Add(oBody.Name)
	Next
	Dim sSelectedBodyName As String = InputListBox("Pick Body Name", oBodyNames, "", "Body Names")
	If sSelectedBodyName Is Nothing OrElse sSelectedBodyName = "" Then Return
	Dim oSelectedBody As SurfaceBody = Nothing
	For Each oBody As SurfaceBody In oBodies
		If oBody.Name = sSelectedBodyName Then
			oSelectedBody = oBody
			Exit For
		End If
	Next
	If oSelectedBody Is Nothing Then Return
	Dim oObjColl As Inventor.ObjectCollection = oInvApp.TransientObjects.CreateObjectCollection
	Dim oDCurves As DrawingCurvesEnumerator = Nothing
	Try : oDCurves = oView.DrawingCurves(oSelectedBody) : Catch : End Try
	If oDCurves Is Nothing OrElse oDCurves.Count = 0 Then Return
	For Each oDCurve As DrawingCurve In oDCurves
		For Each oDCS As DrawingCurveSegment In oDCurve.Segments
			oObjColl.Add(oDCS)
		Next oDCS
	Next oDCurve
	Dim oTrans As Inventor.Transaction = oInvApp.TransactionManager.StartTransaction(oDDoc, "Hide Body Curves - iLogic")
	oDDoc.SelectSet.SelectMultiple(oObjColl)
	oInvApp.CommandManager.ControlDefinitions("DrawingEntityVisibilityCtxCmd").Execute
	oTrans.End
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)