Turning off object visibility - all working features and sketches in IAM and IPT

Turning off object visibility - all working features and sketches in IAM and IPT

kmcga
Contributor Contributor
2,556 Views
10 Replies
Message 1 of 11

Turning off object visibility - all working features and sketches in IAM and IPT

kmcga
Contributor
Contributor

Dear Community,

 

for some reason I need iLogic rule to turn off Object Visibility of Working Features, sketches and so on (see attachment).

I tried script from this link: https://forums.autodesk.com/t5/inventor-forum/automatically-turning-off-workfeatures/m-p/3816449#M46... but it doesn't work for me, some planes still remains after the rule execution.

I just need something that will umark exactly the checkboxes indicated in the attached screenshot, for parts and assemblies.

I am using Inventor 2021.3.

 

Could you support me in this issue?

Thank you in advance.

 

Krzysztof

0 Likes
Accepted solutions (2)
2,557 Views
10 Replies
Replies (10)
Message 2 of 11

JelteDeJong
Mentor
Mentor
Accepted solution

There is no good way to do this but there is an ugly way. It is a problem that the rule can't detect if visibility is on or of. It will just toggle the settings. But if you have everything on then this script will toggle everything off (And on again if you run it a 2e time)

ThisApplication.CommandManager.ControlDefinitions.Item("AppAllWorkfeaturesCmd").Execute()
' --------
ThisApplication.CommandManager.ControlDefinitions.Item("AppConstructionSurfacesVisibilityCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("AppSketchesVisibilityCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("App3DSketchesVisibilityCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("AppSketchDimensionsVisibilityCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("App3DAnnotationsVisibilityCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("App3DCompAnnotationsVisibilityCmd").Execute()
' Weld visability misbehaves so we need to execute it 2 times to make it toggle correct
ThisApplication.CommandManager.ControlDefinitions.Item("WeldmentSymbolsCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("WeldmentGlobalVisibilityCmd").Execute()
ThisApplication.CommandManager.ControlDefinitions.Item("WeldmentSymbolsCmd").Execute()

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 11

kmcga
Contributor
Contributor

Thank you!

0 Likes
Message 4 of 11

JelteDeJong
Mentor
Mentor
Accepted solution

Here is a better solution. (Credits to @engilic for finding these properties)

' https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-2386A49E-2B0C-41F5-9CC0-8FFB2A8CFF79
Dim doc As AssemblyDocument = ThisDoc.Document
Dim vis = doc.ObjectVisibility

If (vis.AllWorkFeatures) Then
    vis.AllWorkFeatures = False
    vis.ConstructionSurfaces = False
    vis.Sketches = False
    vis.Sketches3D = False
    vis.SketchDimensions = False
    vis.Annotations3D = False
    vis.ComponentAnnotations3D = False
    vis.Welds = False
    vis.WeldmentSymbols = False
Else
    vis.AllWorkFeatures = True
    vis.ConstructionSurfaces = True
    vis.Sketches = True
    vis.Sketches3D = True
    vis.SketchDimensions = True
    vis.Annotations3D = True
    vis.ComponentAnnotations3D = True
    vis.Welds = True
    vis.WeldmentSymbols = True
End If

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 11

J.VandeMerckt
Advocate
Advocate

Hi!
Is it possible to get the original value of a workfeature state and use this later in the code?
I've tried this:

	'Get
	Dim oOriginalAllWorkfeatures As Boolean
	oOriginalAllWorkfeatures = oDoc.ObjectVisibility.AllWorkFeatures
	'Set original value
	oDoc.ObjectVisibility.AllWorkFeatures = oOriginalAllWorkfeatures

But it seems to give an error

Error on line 53 in rule: ThumbnailCreator, in document: Part2

Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

This is part of a larger code btw

0 Likes
Message 6 of 11

_dscholtes_
Advocate
Advocate

@J.VandeMerckt 

Yes, that should be possible. I tested your code and it works for me.

 

I changed your code a little to get it running: I changed the 'oDoc' variable because it wasn't declared in your example, added the NOT in line 9 to force a change and check this change in the GUI / menus and added a few message boxes to see where it would crash, but it just worked.

 

'Get
Dim oOriginalAllWorkfeatures As Boolean
oOriginalAllWorkfeatures = ThisDoc.Document.ObjectVisibility.AllWorkFeatures
	
MessageBox.Show(oOriginalAllWorkfeatures, "Title")

	
'Set original value
ThisDoc.Document.ObjectVisibility.AllWorkFeatures = Not  OriginalAllWorkfeatures
	
MessageBox.Show(ThisDoc.Document.ObjectVisibility.AllWorkFeatures, "Title")

 

 

 

Message 7 of 11

J.VandeMerckt
Advocate
Advocate

Yes my apologies, this code is part of a much bigger one.
I'll try to implement your adaption when I have some time.
I assume I will just need to remove the "not" on line 9 and it should work fine.

Thank you.

0 Likes
Message 8 of 11

_dscholtes_
Advocate
Advocate

I don't expect my changes will solve your issue as they did not essentially change the workings of the code.
Unless the ThisDoc.Document part solves it (then there's something unexpected in assinging oDoc), I expect the problem to be elsewhere in your code.

Message 9 of 11

J.VandeMerckt
Advocate
Advocate

In a class I declared oDoc As Document and in my Sub main oDoc = ThisApplication.ActiveDocument.
So not sure if it is maybe not possible in ThisApplication.ActiveDocument
I havn't found the time to test it yet.

0 Likes
Message 10 of 11

nathan_m_gardner
Enthusiast
Enthusiast

I can not get this to work on my parts. is this the full code? i am not a coder so I don't know what I am doing. thanks

0 Likes
Message 11 of 11

J.VandeMerckt
Advocate
Advocate

This is not full code.
You could try to use this snippet to turn AllWorkFeatures on or off with "True" or "False".

 

ThisDoc.Document.ObjectVisibility.AllWorkFeatures = False

 

I haven't tested it so I'm not sure if it works.

 

0 Likes