Hello,
I have a rule that turns off all work geometry and sketches of an assembly and all referenced parts and assemblies.
This rule is almost perfect.
When i run the rule. All sketches and work geometry are turned off. But sketches in sub assemblies remain visible in the top assembly. When i open the document of the sub assembly the sketches are off.
So what I see is a top assembly 'override' of sketch visibility inside sub assemblies
How can I turn off visibility of a sketch on a level higher?
Thanks in advance,
Arnold
Solved! Go to Solution.
Hi,
You have to make the sketches invisible in the context of the main assembly.
To do that you can get all the leaf occurrences inside the main assembly and then get the proxy of the work geometry / sketch proxy through those occurrences.
The following code has a different logic as it's for drawing documents, but I think everything that you'd need is there:
I hope this helps.
Cheers,
I can't understand how to set visibility of these 'proxies' on assembly level
For drawings you use:
Call oDrawView.SetVisibility(oFeatureProxy, False)
But how do I turn off visibility on assembly?
maybe I'm missing something here, but can you just stimply use this? The following code is the same the object visibility panel on the view ribbon in an assembly document:
AssemblyDocument.ObjectVisibility.AllWorkFeatures = False
AssemblyDocument.ObjectVisibility.Sketches = False
AssemblyDocument.ObjectVisibility.Sketches3D = False
Hi Arnold,
I've just written a blog post which I hope does exactly what you are looking for: http://adndevblog.typepad.com/manufacturing/2013/06/set-visibility-of-sketch-in-sub-assembly.html
Cheers,
@Anonymous wrote:maybe I'm missing something here, but can you just stimply use this? The following code is the same the object visibility panel on the view ribbon in an assembly document:
AssemblyDocument.ObjectVisibility.AllWorkFeatures = False
AssemblyDocument.ObjectVisibility.Sketches = False
AssemblyDocument.ObjectVisibility.Sketches3D = False
When many workfeatures are on, you get a orange mess of workplanes and axes.
AssemblyDocument.ObjectVisibility.AllWorkFeatures = False solves this (ribbon bar - View - Object Visibility)
Your method does not allow me to turn everything off and then turn only 1 feature on in particular.
@adam.nagy wrote:Hi Arnold,
I've just written a blog post which I hope does exactly what you are looking for: http://adndevblog.typepad.com/manufacturing/2013/06/set-visibility-of-sketch-in-sub-assembly.html
Cheers,
I can see how you go through every feature and create a proxy.
I have already changed code in your previous post to get this:
Dim oDoc As Document = ThisDoc.Document
Dim oCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oLeafOccs As ComponentOccurrencesEnumerator = oCompDef.Occurrences.AllLeafOccurrences
Dim oOcc As ComponentOccurrence
Dim oWorkSurface As WorkSurface
Dim oSurface As SurfaceBody
Dim oFeature As PartFeature
Dim oFeatureProxy As Object
For Each oOcc In oLeafOccs
For Each oWorkSurface In oOcc.Definition.WorkSurfaces
For Each oSurface In oWorkSurface.SurfaceBodies
oFeature = oSurface.CreatedByFeature
oOcc.CreateGeometryProxy(oFeature, oFeatureProxy)
MsgBox(oFeatureProxy.Name)
Next
Next
Next
You get all the features and make a proxy.
Then turn it off on the drawing using:
Dim baseView As DrawingView Set baseView = dwg.Sheets(1).DrawingViews(1)
Call baseView.SetVisibility(skProxy, False)
The part that I am missing is: How do I do this last part in an assembly?
I can't find a: oAsmDoc.SetVisibility
Is it possible through API to turn off workfeatures 'overrides' on asembly level?
Hi Arnold,
I thought you wanted to set the sketch visibility inside a subassembly shown inside a drawing view.
That's what I showed.
If instead you want to change the visibility directly inside the main assembly itself, then you can do that through the proxy object if the component occurrence containing the sketch is not associative. So there are two things:
a) if the representation of the occurrence containing the sketch is associative and you want to keep it that way, then you should change the sketch visibility directly inside the subassembly document that contains the sketch
You can check if the representation is associative by right-clicking on the occurrence inside the model borswer and select "Representation..." and see if the "Associative" check box is ticked or not
b) if the representation is not associative, then you should be able to change the visibility directly through the proxy. E.g. PlanarSketchProxy.Visible = False
Cheers,
I still have some troubles with this.
To be absolutely clear in what i would like to know, I rewrite my initial question:
I am working on a script for an assemblydocument to turn off all workfeatures, surfaces and sketches in that assembly with the push of a button before placing in the vault. It's like when you are finished building a house, you remove the scaffolding before you sell it.
So far the script turns off workfeatures inside all referenced documents.
But workfeatures that have visiblitiy overrides on assembly level, remain on. I wish to turn these off aswell
These overrides need to be adressed by something called proxies.
This is where I need some help.
I might not grasp the whole proxy idea and how to make proper code with it.
How to link to a workplane or sketch with a proxy or object and then turn it off. I just dont get it.
It might be very simple, but I do not understand.
If someone could shed some light on this, I'm very grateful
Thx in advance,
Arnold
Hi Arnold,
I hope this post will help you understand proxies: http://adndevblog.typepad.com/manufacturing/2013/07/occurrences-contexts-definitions-proxies.html
Cheers,
Great, thanks for the information. I've got it working!
Scripting can be so frustrating now and then.
Dim oDoc As Document = ThisDoc.Document
Dim oCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oLeafOccs As ComponentOccurrencesEnumerator = oCompDef.Occurrences.AllLeafOccurrences
Dim RefPartDef As PartComponentDefinition
Dim RefAssyDef As AssemblyComponentDefinition
Dim oOcc As ComponentOccurrence
Dim RefPlanes As WorkPlanes
Dim RefPlane As WorkPlane
Dim ProxyPlane As WorkPlaneProxy
For Each oOcc In oLeafOccs
If oOcc.suppressed = False Then
If oOcc.DefinitionDocumentType = kPartDocumentObject Then
RefPartDef = oOcc.Definition
RefPlanes = RefPartDef.WorkPlanes
For Each RefPlane In RefPlanes
oOcc.CreateGeometryProxy(RefPlane, ProxyPlane)
ProxyPlane.Visible = False
Next
ElseIf oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
RefAssyDef = oOcc.Definition
End If
End If
Next
InventorVb.DocumentUpdate()
To bad I can only give you 1 kudo for it. This approach also works for all other workgeometry.
If there is a better way to solve my issue, I am still interested to learn.
Thanks
Can't find what you're looking for? Ask the community or share your knowledge.