I have this code that toggles Visibility of work surfaces. I have tried to modify it so it would suppress instead, but failed. I thought i could just swap "visibility" with "IsActive" but that did not work. Would anyone have an idea how to make this work? Thanks.
ORIGINAL CODE:
'Sub HideSurfacesInAsm() 'catch and skip errorsOn Error Resume Next 'define the active assemblyDim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oSurfacebody As WorkSurface Dim Vis As Boolean Dim result result = MsgBox("Make all surfaces visible?", vbYesNoCancel) Select Case result Case vbYes Vis = True Case vbNo Vis = False Case vbCancel Exit Sub End Select Dim oDoc As Inventor.Document For Each oDoc In oAssyDoc.AllReferencedDocuments For Each oSurfacebody In oDoc.ComponentDefinition.WorkSurfaces oSurfacebody.Visible = Vis Next Next ThisApplication.ActiveDocument.Update 'End Sub
MODIFIED CODE:
'Sub HideSurfacesInAsm() 'catch and skip errorsOn Error Resume Next 'define the active assemblyDim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oSurfacebody As WorkSurface Dim SUPPR As Boolean Dim result result = MsgBox("Suppress all surface features?", vbYesNoCancel) Select Case result Case vbNo SUPPR = True Case vbYes SUPPR = False Case vbCancel Exit Sub End Select Dim oDoc As Inventor.Document For Each oDoc In oAssyDoc.AllReferencedDocuments For Each oSurfacebody In oDoc.ComponentDefinition.WorkSurfaces oSurfacebody.IsActive = SUPPR Next Next ThisApplication.ActiveDocument.Update
As with most things, if you can't do it using the GUI, it probably isnt available thru the API. When you right click on a work plane, suppress isn't an option. If you look in the programming help it also doesn't have a suppress method. I'm wondering why you have a need to suppress vs just turning the visibility off.
Hello Ktomberlain,
I have an add on that automatically creates feature cuts. For example all of my hardware in the assembly cuts its own holes. Each hole creates a surface body for itself in the part file. In order to suppress the feature holes so they do not create hidden lines on certain drawings, the surfaces created need to be suppressed. The code for Visibilties purpose is so my extents box is the correct size. Hope that makes sense... little hard to summarize.
I've got a pretty good visual of what your need was, Interesting add-on. I'm wondering if you couldn't just subtract a constant value to calcualate a new extents number. You could probably query the assembly to validate the existance of a plane on any of the faces to know whether or not you need to use the current value of extents or the modified value. Just a thought.