<?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: Rule searches for virtual parts. in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12373109#M160230</link>
    <description>&lt;P&gt;Hello, thank you for the response. I tried the rule you wrote, but I don't get any effect. I created a virtual part with the same name as the assembly from which I launch it, the rule runs but nothing happens. Rather than the assembly name, I would need it to look at the part number though.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2023 07:22:39 GMT</pubDate>
    <dc:creator>tecnico</dc:creator>
    <dc:date>2023-11-13T07:22:39Z</dc:date>
    <item>
      <title>Rule searches for virtual parts.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12368431#M160184</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello everyone, I've tried searching but I can't find a solution to my problem. I need to create a rule that checks if, in my assembly (only first level), there is a Virtual Part with the same name as the assembly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thank&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 12:34:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12368431#M160184</guid>
      <dc:creator>tecnico</dc:creator>
      <dc:date>2023-11-10T12:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Rule searches for virtual parts.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12369505#M160200</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4768144"&gt;@tecnico&lt;/a&gt;.&amp;nbsp; Here is something you can try for that task.&amp;nbsp; First, it makes sure it is working with an assembly (not a part or drawing).&amp;nbsp; Then it gets the components collection.&amp;nbsp; Then iterates through them, skipping any that are suppressed, and if a 'virtual' one is found, it compares the first part of that components name to the DisplayName of the main assembly.&amp;nbsp; If a match is found, a message will pop-up and let you know.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
		MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
		Exit Sub
	End If
	Dim oADoc As AssemblyDocument = ThisDoc.Document
	Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.Suppressed Then Continue For 'cant access Definition if Suppressed
		If TypeOf oOcc.Definition Is VirtualComponentDefinition Then
			If oOcc.Name.StartsWith(oADoc.DisplayName) Then
				MsgBox("Found a Virtual component with same name as main assembly.", vbInformation, "iLogic")
			End If
		End If
	Next 'oOcc
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;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 19:20:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12369505#M160200</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-11-10T19:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rule searches for virtual parts.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12373109#M160230</link>
      <description>&lt;P&gt;Hello, thank you for the response. I tried the rule you wrote, but I don't get any effect. I created a virtual part with the same name as the assembly from which I launch it, the rule runs but nothing happens. Rather than the assembly name, I would need it to look at the part number though.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 07:22:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12373109#M160230</guid>
      <dc:creator>tecnico</dc:creator>
      <dc:date>2023-11-13T07:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rule searches for virtual parts.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12373842#M160250</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4768144"&gt;@tecnico&lt;/a&gt;.&amp;nbsp; OK.&amp;nbsp; Here is a slightly different version of the code, but this version compares the Part Number of the main assembly to the Part Number of the virtual component.&amp;nbsp; And also uses a Boolean to let you know if no match was found after the loop.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
		MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
		Exit Sub
	End If
	Dim oADoc As AssemblyDocument = ThisDoc.Document
	Dim sAssemblyPN As String = oADoc.PropertySets.Item(3).Item(2).Value
	Dim bFound As Boolean = False
	Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
	For Each oOcc As ComponentOccurrence In oOccs
		If oOcc.Suppressed Then Continue For 'cant access Definition if Suppressed
		If TypeOf oOcc.Definition Is VirtualComponentDefinition Then
			Dim oVCD As VirtualComponentDefinition = oOcc.Definition
			Dim sVOccPN As String = oVCD.PropertySets.Item(3).Item(2).Value
			If sVOccPN.Equals(sAssemblyPN, StringComparison.CurrentCultureIgnoreCase) Then
				bFound = True
				MsgBox("Found a Virtual component with same Part Number as main assembly.", vbInformation, "iLogic")
			End If
		End If
	Next 'oOcc
	If bFound = False Then
		MsgBox("Did not find a Virtual component with same Part Number as main assembly.", vbInformation, "iLogic")
	End If
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 13:47:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/rule-searches-for-virtual-parts/m-p/12373842#M160250</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-11-13T13:47:17Z</dc:date>
    </item>
  </channel>
</rss>

