<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: iLogic coding help. in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-coding-help/m-p/13101210#M4990</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14012149"&gt;@andrew_wade1&lt;/a&gt;.&amp;nbsp; This task has been a relatively popular one on this forum over the years, so if you used the search functionality of this forum, you will likely see lots of other conversations about it, and lots of other example codes you could try out.&amp;nbsp; Many of them only turn off work features, such as WorkPoints, WorkAxes, and WorkPlanes, but some also work with other types of things.&amp;nbsp; Below is an example iLogic rule you can try out for a task like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this can be a relatively complex task, with lots of different aspects and details involved, each of which may cause this task to not work exactly as planned.&amp;nbsp; Visibility settings are saved within the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-DesignViewRepresentations" target="_blank" rel="noopener"&gt;DesignViewRepresentations&lt;/A&gt; that are within the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-RepresentationsManager" target="_blank" rel="noopener"&gt;RepresentationsManager&lt;/A&gt; of the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-PartComponentDefinition" target="_blank" rel="noopener"&gt;ComponentDefinition&lt;/A&gt;, within each document.&amp;nbsp; Then, every individual assembly component occurrence can each have their DVR (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-DesignViewRepresentation" target="_blank" rel="noopener"&gt;DesignViewRepresentation&lt;/A&gt;) set differently, which potentially means different appearances or visibility settings.&amp;nbsp; If you are not using all the DVR settings along the way in each document and in each occurrence, then this may not work properly for you.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oDoc As Inventor.Document = ThisDoc.Document
	Dim oTrans As Inventor.Transaction
	oTrans = ThisApplication.TransactionManager.StartTransaction(oDoc, "Set Visibility - iLogic")
	SetVisibility(oDoc, False)
	Dim oRefDocs As DocumentsEnumerator = oDoc.AllReferencedDocuments
	For Each oRefDoc As Inventor.Document In oRefDocs
		SetVisibility(oRefDoc, False)
	Next oRefDoc
	oDoc.Update2(True)'do not use 'If oDoc.RequiresUpdate', it will be False
	oTrans.End
	'If oDoc.Dirty Then oDoc.Save2(True)
End Sub

Sub SetVisibility(oDoc As Document, bVisible As Boolean)
	If oDoc Is Nothing OrElse oDoc.IsModifiable = False Then Return
	If (Not TypeOf oDoc Is AssemblyDocument) AndAlso (Not TypeOf oDoc Is PartDocument) Then Return
	Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
	For Each oWA As WorkAxis In oCD.WorkAxes
		If oWA.Visible &amp;lt;&amp;gt; bVisible Then oWA.Visible = bVisible
	Next
	For Each oWP As WorkPlane In oCD.WorkPlanes
		If oWP.Visible &amp;lt;&amp;gt; bVisible Then oWP.Visible = bVisible
	Next
	For Each oWPt As WorkPoint In oCD.WorkPoints
		If oWPt.Visible &amp;lt;&amp;gt; bVisible Then oWPt.Visible = bVisible
	Next
	Try 'assemblies do not have these, only parts
		For Each oWS As WorkSurface In oCD.WorkSurfaces
			If oWS.Visible &amp;lt;&amp;gt; bVisible Then oWS.Visible = bVisible
		Next
	Catch : End Try
	For Each oSketch As PlanarSketch In oCD.Sketches
		If oSketch.Visible &amp;lt;&amp;gt; bVisible Then oSketch.Visible = bVisible
	Next
	Try 'assemblies do not have these, only parts
		For Each o3DSketch As Sketch3D In oCD.Sketches3D
			If o3DSketch.Visible &amp;lt;&amp;gt; bVisible Then o3DSketch.Visible = bVisible
		Next
	Catch : End Try
	For Each oMA As ModelAnnotation In oCD.ModelAnnotations
		If oMA.Visible &amp;lt;&amp;gt; bVisible Then oMA.Visible = bVisible
	Next
	'oDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Oct 2024 18:16:01 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-10-22T18:16:01Z</dc:date>
    <item>
      <title>iLogic coding help.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-coding-help/m-p/13100750#M4988</link>
      <description>&lt;P&gt;I am looking to write a iLogic code to turn off visibility of planes, sketches, datums, points... To help clean up both part and assembly files. At the same time at the end bring the part or assembly back to home and fit. I have started with basic vb code and kind of got it to work with the parts but not the assembly. Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 15:15:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-coding-help/m-p/13100750#M4988</guid>
      <dc:creator>andrew_wade1</dc:creator>
      <dc:date>2024-10-22T15:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic coding help.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-coding-help/m-p/13101093#M4989</link>
      <description>&lt;P&gt;Here is a very basic set of code to turn off the object visibility and set the view to home. There are a lot of options within the object visibility that you can dig deeper into. This acts the same as just turning off the object visibility in the View tab of the ribbon.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;()
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;doc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;objVis&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ObjectVisibility&lt;/SPAN&gt; = &lt;SPAN&gt;doc&lt;/SPAN&gt;.&lt;SPAN&gt;ObjectVisibility&lt;/SPAN&gt;
	
	&lt;SPAN&gt;objVis&lt;/SPAN&gt;.&lt;SPAN&gt;AllWorkFeatures&lt;/SPAN&gt; = &lt;SPAN&gt;False&lt;/SPAN&gt;
	
	&lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;ControlDefinitions&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;"AppViewCubeHomeCmd"&lt;/SPAN&gt;).&lt;SPAN&gt;Execute&lt;/SPAN&gt;
    &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveView&lt;/SPAN&gt;.&lt;SPAN&gt;Fit&lt;/SPAN&gt;
	
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;'Main&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 17:28:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-coding-help/m-p/13101093#M4989</guid>
      <dc:creator>patrick.schlambHPACQ</dc:creator>
      <dc:date>2024-10-22T17:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic coding help.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-coding-help/m-p/13101210#M4990</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14012149"&gt;@andrew_wade1&lt;/a&gt;.&amp;nbsp; This task has been a relatively popular one on this forum over the years, so if you used the search functionality of this forum, you will likely see lots of other conversations about it, and lots of other example codes you could try out.&amp;nbsp; Many of them only turn off work features, such as WorkPoints, WorkAxes, and WorkPlanes, but some also work with other types of things.&amp;nbsp; Below is an example iLogic rule you can try out for a task like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this can be a relatively complex task, with lots of different aspects and details involved, each of which may cause this task to not work exactly as planned.&amp;nbsp; Visibility settings are saved within the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-DesignViewRepresentations" target="_blank" rel="noopener"&gt;DesignViewRepresentations&lt;/A&gt; that are within the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-RepresentationsManager" target="_blank" rel="noopener"&gt;RepresentationsManager&lt;/A&gt; of the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-PartComponentDefinition" target="_blank" rel="noopener"&gt;ComponentDefinition&lt;/A&gt;, within each document.&amp;nbsp; Then, every individual assembly component occurrence can each have their DVR (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-DesignViewRepresentation" target="_blank" rel="noopener"&gt;DesignViewRepresentation&lt;/A&gt;) set differently, which potentially means different appearances or visibility settings.&amp;nbsp; If you are not using all the DVR settings along the way in each document and in each occurrence, then this may not work properly for you.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oDoc As Inventor.Document = ThisDoc.Document
	Dim oTrans As Inventor.Transaction
	oTrans = ThisApplication.TransactionManager.StartTransaction(oDoc, "Set Visibility - iLogic")
	SetVisibility(oDoc, False)
	Dim oRefDocs As DocumentsEnumerator = oDoc.AllReferencedDocuments
	For Each oRefDoc As Inventor.Document In oRefDocs
		SetVisibility(oRefDoc, False)
	Next oRefDoc
	oDoc.Update2(True)'do not use 'If oDoc.RequiresUpdate', it will be False
	oTrans.End
	'If oDoc.Dirty Then oDoc.Save2(True)
End Sub

Sub SetVisibility(oDoc As Document, bVisible As Boolean)
	If oDoc Is Nothing OrElse oDoc.IsModifiable = False Then Return
	If (Not TypeOf oDoc Is AssemblyDocument) AndAlso (Not TypeOf oDoc Is PartDocument) Then Return
	Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
	For Each oWA As WorkAxis In oCD.WorkAxes
		If oWA.Visible &amp;lt;&amp;gt; bVisible Then oWA.Visible = bVisible
	Next
	For Each oWP As WorkPlane In oCD.WorkPlanes
		If oWP.Visible &amp;lt;&amp;gt; bVisible Then oWP.Visible = bVisible
	Next
	For Each oWPt As WorkPoint In oCD.WorkPoints
		If oWPt.Visible &amp;lt;&amp;gt; bVisible Then oWPt.Visible = bVisible
	Next
	Try 'assemblies do not have these, only parts
		For Each oWS As WorkSurface In oCD.WorkSurfaces
			If oWS.Visible &amp;lt;&amp;gt; bVisible Then oWS.Visible = bVisible
		Next
	Catch : End Try
	For Each oSketch As PlanarSketch In oCD.Sketches
		If oSketch.Visible &amp;lt;&amp;gt; bVisible Then oSketch.Visible = bVisible
	Next
	Try 'assemblies do not have these, only parts
		For Each o3DSketch As Sketch3D In oCD.Sketches3D
			If o3DSketch.Visible &amp;lt;&amp;gt; bVisible Then o3DSketch.Visible = bVisible
		Next
	Catch : End Try
	For Each oMA As ModelAnnotation In oCD.ModelAnnotations
		If oMA.Visible &amp;lt;&amp;gt; bVisible Then oMA.Visible = bVisible
	Next
	'oDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 18:16:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-coding-help/m-p/13101210#M4990</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-22T18:16:01Z</dc:date>
    </item>
  </channel>
</rss>

