11-21-2024
10:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-21-2024
10:12 AM
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:
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)
.
Wesley Crihfield
(Not an Autodesk Employee)