- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If I were to control the visibility of one body, how would I write the code for that
It's a yes or no function I'm looking for
Parameter (Parameter name: Sliderail)
Yes
No
Bodyname
Sliderail, round
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
try this:
Version:1.0 StartHTML:00000145 EndHTML:00002241 StartFragment:00000294 EndFragment:00002209 StartSelection:00000294 EndSelection:00000294SyntaxEditor Code Snippet
Dim oApp As Application Dim oPD As PartDocument Dim oPCD As PartComponentDefinition Dim oSurfBody As SurfaceBody oApp = ThisApplication oPD = oApp.ActiveDocument oPCD = oPD.ComponentDefinition For Each oSurfBody In oPCD.SurfaceBodies If oSurfBody.Name = "Sliderail" Then oSurfBody.Visible = False End If Next
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You can add more condition
Dim oApp As Application Dim oPD As PartDocument Dim oPCD As PartComponentDefinition Dim oSurfBody As SurfaceBody oApp = ThisApplication oPD = oApp.ActiveDocument oPCD = oPD.ComponentDefinition For Each oSurfBody In oPCD.SurfaceBodies If oSurfBody.Name = "Sliderail" Then if Sliderail = "Yes" then
oSurfBody.Visible = True
else
oSurfBody.Visible = False
end if End If Next
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What if you have the paramter options and 2 bodies?
Parameter (Parameter name: Sliderail)
No (...None of the 2 bodies are vissible)
Round (Sliderail, round is visible)
Square (Sliderail, Square is visible)
Bodynames
Sliderail, round
Sliderail, square
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim oApp As Application
Dim oPD As PartDocument
Dim oPCD As PartComponentDefinition
Dim oSurfBody As SurfaceBody
oApp = ThisApplication
oPD = oApp.ActiveDocument
oPCD = oPD.ComponentDefinition
For Each oSurfBody In oPCD.SurfaceBodies
if Sliderail = "No" then
if oSurfBody.Name = "Sliderail, round" or oSurfBody.Name = "Sliderail, Square" then
oSurfBody.Visible = False
else
osurfbody.visible = true
End if
ElseIf Sliderail = "Round" Then
If oSurfBody.Name = "Round" Then
oSurfBody.Visible = True
else
oSurfBody.Visible = False
end if
ElseIf Sliderail = "Square" Then
If oSurfBody.Name = "Square" Then
oSurfBody.Visible = True
else
oSurfBody.Visible = False
End if
End if
Next
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Awesome. Thank You!
What if I had 3 extra bodies that should be visible at all times. How would that affect the code
Lets just call them
body1
body2
body3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
you can try, let me know if there are error.
Autodesk Inventor Professional Certified 2014