SolidBody visibility

SolidBody visibility

Anonymous
Not applicable
557 Views
3 Replies
Message 1 of 4

SolidBody visibility

Anonymous
Not applicable

Hi everyone,

Here is my rule in ilogic,

'catch and skip errors
On Error Resume Next
'define the active assembly
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument
'define Sb as solidbodies
Dim SB As SurfaceBody
'define ShellB as a surfacebodies
Dim ShellB As WorkSurface
'define Vis and Vis2 as boolean type
Dim Vis As Boolean
Dim Vis2 As Boolean

'choose solid or surface bodies
If solidOrShell = "Solid" Then
	Vis = True
	Vis2 = False
Else If solidOrShell = "Shell" Then
	Vis = False
	Vis2 = True

End If

Dim oDoc As Inventor.Document

For Each oDoc In oAssyDoc.AllReferencedDocuments
    
    For Each SB In oDoc.ComponentDefinition.SurfaceBodies
        SB.Visible = Vis
    Next
	For Each ShellB In oDoc.ComponentDefinition.WorkSurfaces
		ShellB.Visible = Vis2
		Next
Next
ThisApplication.ActiveDocument.Update

after i changed solid body to surface I would like to leave some elements as solid.

 

How can i do this ?

 

KS

0 Likes
Accepted solutions (1)
558 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

What criteria do you want to filter by? 

 

You can filter them out in your For loop. 

'For Each oDoc in oAssyDoc.AllReferencedDocuments
If somecriteria = True Then
For Each SB In oDoc.ComponentDefinition.SurfaceBodies
         SB.Visible = Vis
     Next
     For Each ShellB In oDoc.ComponentDefinition.WorkSurfaces
         ShellB.Visible = Vis2
        Next
End If
Next
Message 3 of 4

Anonymous
Not applicable

the for loop is a good solution.

but I am looking for a simpler solution.

I know exactly which element should change its visibilitytree.PNG

 

 

as here in the assembly I want to change the visibility SB in "bMainStrop" part

I'm looking for a solution something like this

 

SyntaxEditor Code Snippet

Feature.IsActive("Part1:1", "featurename")

 

 

 

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Here is a solution, but if somebody can do it easier please show us your code 🙂

SyntaxEditor Code Snippet

'catch and skip errors
On Error Resume Next
'define the active assembly
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument

Dim oDoc As Inventor.Document
'define Sb as solidbodies
Dim SB As SurfaceBody
'define ShellB as a surfacebodies
Dim ShellB As WorkSurface
'define Vis and Vis2 as boolean type
Dim Vis As Boolean
Dim Vis2 As Boolean
'define parts name
Dim gniazdo1 As String
gniazdo1 = "gniazdo1.ipt"
Dim gniazdo1_MIR As String
gniazdo1_MIR = "gniazdo1_MIR.ipt"
Dim gniazdo As String
gniazdo = "gniazdo.ipt"
Dim gniazdo_MIR As String
gniazdo_MIR = "gniazdo_MIR.ipt"

'choose solid or surface bodies
If solidOrShell = "Solid" Then
    Vis = True
    Vis2 = False
Else If solidOrShell = "Shell" Then
    Vis = False
    Vis2 = True

End If


For Each oDoc In oAssyDoc.AllReferencedDocuments
'   define name of part
    Dim FNamePos As Long
    FNamePos = InStrRev(oDoc.FullFileName, "\", -1)
    Dim docFName As String 
    docFName = oDoc.FullFileName
    docFName = Right(oDoc.FullFileName, Len(oDoc.FullFileName) - FNamePos)

'   verify condition
     If gniazdo = docFName Or gniazdo_MIR = docFName Or gniazdo1 = docFName Or gniazdo1_MIR = docFName Then
           For Each SB In oDoc.ComponentDefinition.SurfaceBodies
            SB.Visible = True
        Next
    Else
        For Each SB In oDoc.ComponentDefinition.SurfaceBodies
            SB.Visible = Vis
        Next
        For Each ShellB In oDoc.ComponentDefinition.WorkSurfaces
            ShellB.Visible = Vis2
        Next
    End If    
Next
ThisApplication.ActiveDocument.Update

 

KS 

0 Likes