Hello,
I have code to disable the visibility of all workfeatures. But in the main assembler I can still see workplanes. This type is workplaceproxy, how can I disable the visibility of these workplanes?
Sub OffFeatures2()
Dim oAssyDoc As AssemblyDocument
Set oAssyDoc = ThisApplication.ActiveDocument
Call offAllFeature(oAssyDoc, False)
For Each oDoc In oAssyDoc.AllReferencedDocuments
Call offAllFeature(oDoc, False)
Next
Dim oCCs As ComponentOccurrences
Set oCCs = oAssyDoc.ComponentDefinition.Occurrences
End Sub
Sub offAllFeature(oDoc As Document, wfBoolean As Boolean)
For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
oWorkPlane.Visible = wfBoolean
Next
For Each oWorkAxis In oDoc.ComponentDefinition.WorkAxes
oWorkAxis.Visible = wfBoolean
Next
For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
oWorkPoint.Visible = wfBoolean
Next
For Each oSketch In oDoc.ComponentDefinition.Sketches
oSketch.Visible = wfBoolean
Next
If Not oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
For Each oSketch3D In oDoc.ComponentDefinition.Sketches3D
oSketch3D.Visible = wfBoolean
Next
End If
End Sub
Hi @Hubert_Los. This can be complicated to explain. For one thing, I do not see any code included to update the main assembly after making the changes to all the referenced documents. Also, if any of the referenced documents are ReadOnly, such as from the ContentCenter, or library files, then the changes will not effect them, and may throw errors when you try to make those changes to them. That may be needed before changes to those referenced documents will be seen in the main assembly. Next, since visibility is recorded in DVRs (DVRs = DesignViewRepresentations & DVR = DesignViewRepresentation), you would need to make sure that each component is set to the DVR in which those changes were made, so that the component looks like that while in the assembly. Then, if that component is within a sub assembly, then that sub assembly also has DVRs, and one of them recorded how you set the DVR of each of its components. Then the component representing that sub assembly would need to be set to the DVR where those changes were made. If every component at every level only had its one original DVR, and no others, then this complex process may not be needed. Also, if a component is set to a custom DVR, then there is an additional settings about whether that settings is 'associative' or not' that needs to be kept in mind. If every component that is set to a specific DVR has that property set to True, then its appearance should stay up-to-date with what its referenced model looks like when that DVR in it is active. If that property is False, then the appearance of the component may not stay up-to-date with the model it is referencing. The DVR's should normally be set-up from bottom to top (from the lowest / deepest part, then its parent sub assemblies, then the main assembly).
Wesley Crihfield
(Not an Autodesk Employee)
@WCrihfield
It sounds complex. I'll have to postpone this task until later. Thank you for the explanation.
Can't find what you're looking for? Ask the community or share your knowledge.