11-21-2024
09:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-21-2024
09:59 PM
First of all, thank you for your help, I think I'm almost there, I'm just stuck at this point, I hope you can help me.
I found a code on the forum to hide the body by picking the edge of the body like this (code number 1) :
Dim oOccioV As DrawingCurveSegment
Set oOccioV = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick edge")
Dim oView As DrawingView
Set oView = oOccioV.Parent.Parent
Dim oToccoH As Object
Set oToccoH = oOccioV.Parent.ModelGeometry.Parent
Call oView.SetVisibility(oToccoH, False)
However, the object is declared as Drawing Curve Segment. Your code runs perfectly ok, however, I want to hide the body like right-clicking on the body and selecting Visibility. Is there a way to get the Drawing Curve Segment of a body whose name is known? I think I can combine your code and the code on the forum.
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
'CODE NUMBER 1 HERE
End Sub