<?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: How to Add A Block Name to iProperties in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13064948#M5694</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;.&amp;nbsp; Below is an example of an iLogic rule that you can run on the part.&amp;nbsp; This rule will get the names of all sketch block definitions in the current part, present them to the user, to select one, then write the chosen name to the Description iProperty.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim oSBDNames As New List(Of String)
	For Each oSBD As SketchBlockDefinition In oPDoc.ComponentDefinition.SketchBlockDefinitions
		oSBDNames.Add(oSBD.Name)
	Next oSBD
	Dim sChosenSBDName As String = InputListBox("Choose SketchBlockDefinition Name To Put In Description.", _
	oSBDNames, oSBDNames(0), "SketchBlockDefinition Names", "List of SketchBlockDefinition Names")
	If sChosenSBDName &amp;lt;&amp;gt; "" Then
		'write the chosen name to the Description iProperty
		oPDoc.PropertySets.Item(3).Item(14).Value = sChosenSBDName
	End If
	oPDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Below is another rule that will&amp;nbsp;iterate through every planar sketch in the current part, and iterate through every sketch block in each of those sketches, until it finds the first one, then it writes the name of that sketch block to the Description iProperty.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim sSkBlkName As String = String.Empty
	For Each oSk As PlanarSketch In oPDoc.ComponentDefinition.Sketches
		For Each oSB As SketchBlock In oSk.SketchBlocks
			sSkBlkName = oSB.Name
			Exit For
		Next oSB
		If sSkBlkName &amp;lt;&amp;gt; String.Empty Then Exit For
	Next oSk
	If sSkBlkName &amp;lt;&amp;gt; String.Empty Then
		'write it to the Description iProperty
		oPDoc.PropertySets.Item(3).Item(14).Value = sSkBlkName
	End If
	oPDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;The stuff on the drawing side would then be up to you.&amp;nbsp; Creating notes within drawings by code that include 'linked' pieces of information can be pretty complicated, because it involved 'formatted text', which includes &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-915B75BA-4696-4fc7-A2C6-54B2BACDE7E1" target="_blank" rel="noopener"&gt;XML tags&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&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>Fri, 04 Oct 2024 13:11:17 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-10-04T13:11:17Z</dc:date>
    <item>
      <title>How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13056083#M5687</link>
      <description>&lt;P&gt;There is a 2D block in a sketch in IPT file.&lt;/P&gt;&lt;P&gt;I want to insert the block name to "Description" under "Project" tab in iProperties.&lt;/P&gt;&lt;P&gt;Can it be done?&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 00:54:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13056083#M5687</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-01T00:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13057071#M5688</link>
      <description>&lt;P&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Hi, I think it would need to either be done manually, or possibly with some code. &amp;nbsp;This post can be moved to the Inventor Programming forum if you would like.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 12:40:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13057071#M5688</guid>
      <dc:creator>CGBenner</dc:creator>
      <dc:date>2024-10-01T12:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13057115#M5689</link>
      <description>&lt;P&gt;Can't it just be manually typed in as normal without any special coding? It's not locked, thus editable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 12:55:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13057115#M5689</guid>
      <dc:creator>ldutkaTUZ58</dc:creator>
      <dc:date>2024-10-01T12:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13061054#M5690</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9248770"&gt;@CGBenner&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;In my case, I prefer to have an option of selecting the block name rather than using a code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is ok to move this thread to programming forum.&lt;/P&gt;&lt;P&gt;It may also help others.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 22:54:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13061054#M5690</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-02T22:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13062271#M5691</link>
      <description>&lt;P&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;When you say selecting the block name, how do you envision this working? &amp;nbsp;Selecting it from where?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 12:45:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13062271#M5691</guid>
      <dc:creator>CGBenner</dc:creator>
      <dc:date>2024-10-03T12:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13063738#M5692</link>
      <description>&lt;P&gt;Hahaha, it's a good point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do is inserting the block name to view label in drawing file.&lt;/P&gt;&lt;P&gt;If block name can be available in iProperties then I will be able to insert it to view labels in drawing.&lt;/P&gt;&lt;P&gt;Here is what I mean.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BeKirra_0-1727998269295.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1417672iE8E00B0B334B81B2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BeKirra_0-1727998269295.png" alt="BeKirra_0-1727998269295.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 23:33:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13063738#M5692</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-03T23:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13064880#M5693</link>
      <description>&lt;P&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;&lt;/SPAN&gt; Thank you for that!&lt;BR /&gt;&lt;BR /&gt;I am going to move the post since I believe it will require some code for Inventor to dig the Block Name out of the sketch automatically (if it is even possible at all)... otherwise, I think the workflow you so beautifully drew up for me is possible... but very manual. &amp;nbsp;Let's see what the programming gurus think.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 12:39:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13064880#M5693</guid>
      <dc:creator>CGBenner</dc:creator>
      <dc:date>2024-10-04T12:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13064948#M5694</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;.&amp;nbsp; Below is an example of an iLogic rule that you can run on the part.&amp;nbsp; This rule will get the names of all sketch block definitions in the current part, present them to the user, to select one, then write the chosen name to the Description iProperty.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim oSBDNames As New List(Of String)
	For Each oSBD As SketchBlockDefinition In oPDoc.ComponentDefinition.SketchBlockDefinitions
		oSBDNames.Add(oSBD.Name)
	Next oSBD
	Dim sChosenSBDName As String = InputListBox("Choose SketchBlockDefinition Name To Put In Description.", _
	oSBDNames, oSBDNames(0), "SketchBlockDefinition Names", "List of SketchBlockDefinition Names")
	If sChosenSBDName &amp;lt;&amp;gt; "" Then
		'write the chosen name to the Description iProperty
		oPDoc.PropertySets.Item(3).Item(14).Value = sChosenSBDName
	End If
	oPDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Below is another rule that will&amp;nbsp;iterate through every planar sketch in the current part, and iterate through every sketch block in each of those sketches, until it finds the first one, then it writes the name of that sketch block to the Description iProperty.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim sSkBlkName As String = String.Empty
	For Each oSk As PlanarSketch In oPDoc.ComponentDefinition.Sketches
		For Each oSB As SketchBlock In oSk.SketchBlocks
			sSkBlkName = oSB.Name
			Exit For
		Next oSB
		If sSkBlkName &amp;lt;&amp;gt; String.Empty Then Exit For
	Next oSk
	If sSkBlkName &amp;lt;&amp;gt; String.Empty Then
		'write it to the Description iProperty
		oPDoc.PropertySets.Item(3).Item(14).Value = sSkBlkName
	End If
	oPDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;The stuff on the drawing side would then be up to you.&amp;nbsp; Creating notes within drawings by code that include 'linked' pieces of information can be pretty complicated, because it involved 'formatted text', which includes &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-915B75BA-4696-4fc7-A2C6-54B2BACDE7E1" target="_blank" rel="noopener"&gt;XML tags&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&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>Fri, 04 Oct 2024 13:11:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13064948#M5694</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-04T13:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13070748#M5695</link>
      <description>&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks possible to get the block name using a code.&lt;/P&gt;&lt;P&gt;However, I don't prefer using "Description" as it has usually been used for the part/assembly.&lt;/P&gt;&lt;P&gt;I wish to create a &lt;STRONG&gt;&lt;FONT color="#000000"&gt;New Item&lt;/FONT&gt;&lt;/STRONG&gt; under "Standard iProperties" or "Custom iProperties" (see snapshot below).&lt;/P&gt;&lt;P&gt;Can it be done?&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BeKirra_1-1728364932515.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1418872i6A70EEC96264FA86/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BeKirra_1-1728364932515.png" alt="BeKirra_1-1728364932515.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 05:24:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13070748#M5695</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-08T05:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13071677#M5696</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;.&amp;nbsp; Sure, that detail can be changed.&amp;nbsp; Below is another example iLogic rule, similar to my first example above, but instead of writing the chosen SketchBlock name to the Description property, it attempts to write it to a custom iProperty.&amp;nbsp; We can not 'add' any new items to the 'standard' iProperties, but can add new properties to the custom ones.&amp;nbsp; iProperties are stored within PropertySets.&amp;nbsp; There are always at least 4 of these PropertySet objects within the PropertySets of every document.&amp;nbsp; The first 3 sets are all standard, so we can not add or remove any properties from those sets, and can only change the values of some of them.&amp;nbsp; The fourth set is always the custom one, but it usually is empty (does not contain any custom properties), until we either create some on purpose, or set some of our parameters to export, which automatically creates a custom iProperty for those parameters, with same name and value as the parameter.&amp;nbsp; So, in order to write something to a custom iProperty, we must make sure the property object we want to write it to exists first.&amp;nbsp; Sometimes that requires creating a new custom iProperty, if the one we want to write to does not already exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the most popular ways to handle that situation is to use a &lt;A href="https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/try-catch-finally-statement" target="_blank" rel="noopener"&gt;Try...Catch...End Try statement&lt;/A&gt;, which allows us to 'try' some code that we believe may sometimes cause an error (such as trying to access a named property that does not exist), while avoiding that error, and allows us to do something different when it does block the expected error (such as creating the custom property).&amp;nbsp; That process could also be done differently (without using a Try...Catch statement), by iterating through all existing custom properties, and checking their names, to find the one we want first, if it exists.&amp;nbsp; If found, set its value, but if not found, create it.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim oSBDNames As New List(Of String)
	For Each oSBD As SketchBlockDefinition In oPDoc.ComponentDefinition.SketchBlockDefinitions
		oSBDNames.Add(oSBD.Name)
	Next oSBD
	Dim sChosenSBDName As String = InputListBox("Choose SketchBlockDefinition Name To Put In Description.", _
	oSBDNames, oSBDNames(0), "SketchBlockDefinition Names", "List of SketchBlockDefinition Names")
	If sChosenSBDName &amp;lt;&amp;gt; "" Then
		'write the chosen name to a 'custom' iProperty
		'to do that, we first need to make sure the custom iProperty exists, or create it
		Dim oCProps As Inventor.PropertySet = oPDoc.PropertySets.Item(4) 'always the Custom one
		Dim oCProp As Inventor.Property = Nothing
		Dim sPropName As String = "SketchBlock Name"
		Try 'try to find existing custom iProperty
			oCProp = oCProps.Item(sPropName)
			'if it was found, then set its value
			oCProp.Value = sChosenSBDName
		Catch 'getting the custom property failed, so create it, and set its value at same time
			oCProp = oCProps.Add(sChosenSBDName, sPropName)
		End Try
	End If
	oPDoc.Update2(True) 'update part, ignoring any errors
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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 13:51:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13071677#M5696</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-08T13:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13072964#M5697</link>
      <description>&lt;P&gt;Perfecto and it works as expected.&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 01:09:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13072964#M5697</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-09T01:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13082166#M5698</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I notice the code doesn't show all sketch block names if multiple blocks are added to custom iproperties.&lt;/P&gt;&lt;P&gt;Instead the last adding in block name is shown.&lt;/P&gt;&lt;P&gt;Can all block names be available and selectable?&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2024 23:27:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13082166#M5698</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-13T23:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13083311#M5699</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;.&amp;nbsp;&amp;nbsp;I am not sure I understand&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;I notice the code doesn't show all sketch block names if multiple blocks are added to custom iproperties.&lt;/P&gt;
&lt;P&gt;Instead the last adding in block name is shown.&lt;/P&gt;
&lt;P&gt;Can all block names be available and selectable&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;Are you saying that when you run this rule, you are not seeing the names of all the sketch blocks that are available in the part included in that list dialog, but are only seeing one name in that list dialog?&amp;nbsp; Or are you saying that, after the rule has finished, you are only seeing one block name as the value of the single iProperty, but you were expecting multiple block names to be in that one custom iProperty's value?&amp;nbsp; Unlike user &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-UserParameter" target="_blank" rel="noopener"&gt;UserParameter&lt;/A&gt; object, which has the&amp;nbsp;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=UserParameter_ExpressionList" target="_blank" rel="noopener"&gt;UserParameter.ExpressionList&lt;/A&gt;&amp;nbsp;property, for storing multiple possible values to choose from in a drop-down list, the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-Property" target="_blank" rel="noopener"&gt;Inventor.Property&lt;/A&gt; (iProperty) can only have one value, and does not have any way to store multiple possible values in a list.&amp;nbsp; When we set the value of a property, its previous value is overwritten by the new value.&amp;nbsp; If your intention is...if the custom iProperty already exists, and already has a value, then just add the current block name to the end of the existing value, instead of replacing its current value, then we would have to change how that part of the code works.&amp;nbsp; There is also a way to force the list dialog to allow you to select multiple names at one time, but it is a bit complicated.&amp;nbsp; And if done that way, then not only would the list presentation part of the code need to be changed, but there would also need to be additional changes made, such as adding a loop for iterating through each of the names that were selected in the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, are you wanting a new custom property, with a different name, to be created each time you run the rule, so that each of them contains a single sketch block name.&amp;nbsp; If so, then how should each property be named, so that they are different from each other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to add to a property's existing value, instead of replace its value, you would have to do something like:&lt;/P&gt;
&lt;P&gt;oProperty.Value = oProperty.Value.ToString &amp;amp; sNextValueToAdd&lt;/P&gt;
&lt;P&gt;...where 'oProperty' is a variable representing an existing custom Property, and 'sNextValueToAdd' represents the next piece of data that you would like to add to the property's existing value.&amp;nbsp; Or, you could put multiple String type values together into a single String value, with commas, colons, or some other separator character between each of them.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 13:49:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13083311#M5699</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-14T13:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13084269#M5700</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;If your intention is...if the custom iProperty already exists, and already has a value, then just add the current block name to the end of the existing value, instead of replacing its current value, then we would have to change how that part of the code works.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, it is what I mean.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2024 22:17:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13084269#M5700</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-14T22:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13085512#M5701</link>
      <description>&lt;P&gt;OK.&amp;nbsp; Below is a modified version of the previous code example.&amp;nbsp; In this example, if the custom iProperty already exists, and is found, it will attempt to add the currently selected sketch block name to the end of the custom property's current value, with a comma and a space inserted between the existing value and the new sketch block name, instead of replacing the value of the custom iProperty.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim oSBDNames As New List(Of String)
	For Each oSBD As SketchBlockDefinition In oPDoc.ComponentDefinition.SketchBlockDefinitions
		oSBDNames.Add(oSBD.Name)
	Next oSBD
	Dim sChosenSBDName As String = InputListBox("Choose SketchBlockDefinition Name To Put In Description.", _
	oSBDNames, oSBDNames(0), "SketchBlockDefinition Names", "List of SketchBlockDefinition Names")
	If sChosenSBDName = "" Then Return
	'write the chosen name to a 'custom' iProperty
	'to do that, we first need to make sure the custom iProperty exists, or create it
	Dim oCProps As Inventor.PropertySet = oPDoc.PropertySets.Item(4) 'always the Custom one
	Dim oCProp As Inventor.Property = Nothing
	Dim sPropName As String = "SketchBlock Name"
	'try to find existing custom iProperty, if it exists
	Try : oCProp = oCProps.Item(sPropName) : Catch : End Try
	'if existing was found, then 'add to' its value, instead of replacing its value
	If oCProp IsNot Nothing Then
		oCProp.Value = oCProp.Value.ToString &amp;amp; ", " &amp;amp; sChosenSBDName
	Else 'it was not found, so try to create it
		Try : oCProp = oCProps.Add(sChosenSBDName, sPropName) : Catch : End Try
	End If
	oPDoc.Update2(True) 'update part, ignoring any errors
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, 15 Oct 2024 13:19:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13085512#M5701</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-15T13:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13089775#M5702</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Can each block name starts a new line in "Custom iProperties"?&lt;/P&gt;&lt;P&gt;In this case commas are no longer needed.&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 01:54:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13089775#M5702</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-17T01:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13091043#M5703</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;.&amp;nbsp; It seems like I am going to have to ask some of the same questions again that I asked in Message 13.&amp;nbsp; I already mentioned that a custom iProperty can not have a multi-value list, like a UserParameter can.&amp;nbsp; And I mentioned that the only way to put multiple values in one iProperty is to separate them by something like commas (or by a space, or some other character).&amp;nbsp; I also asked if you wanted multiple custom iProperties...one for each sketch block name.&amp;nbsp; And if so, how should each custom iProperty be named differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you would like me to write/change code to do something for you, I need to know every tiny detail about what you want the code to do, because code needs to be extremely specific for it to work properly.&amp;nbsp; If you want multiple custom iProperties to be created, then there will need to be a naming system integrated into the code, to generate a different name for each one.&amp;nbsp; Not only that, but it will need to know how to find all the existing custom iProperties that are just for sketch block names, and not other stuff, because it will need to find all the existing ones each time, to know which name to use when assigning the 'next' name, so it is not attempting to overwrite an existing property's value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also mentioned in that same message, that there is a way to allow you to select multiple block names at once from the same list, instead of only being able to select one at a time.&amp;nbsp; If we went that route, then the code would know the total number of block names it will be dealing with, and can simply iterate through that collection creating a new property for each of them in a loop.&amp;nbsp; The property name could be the same as the sketch block name, or it could just get an incrementing index integer added onto the end of the name of each property.&amp;nbsp; Just one possible option.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 12:55:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13091043#M5703</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-17T12:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13092440#M5704</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I also mentioned in that same message, that there is a way to allow you to select multiple block names at once from the same list, instead of only being able to select one at a time.&amp;nbsp; If we went that route, then the code would know the total number of block names it will be dealing with, and can simply iterate through that collection creating a new property for each of them in a loop.&amp;nbsp; The property name could be the same as the sketch block name, or it could just get an incrementing index integer added onto the end of the name of each property.&amp;nbsp; Just one possible option.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&lt;/P&gt;&lt;P&gt;1st of all, thanks for your help again.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Sorry I didn't describe it clear. My bad.&lt;/P&gt;&lt;P&gt;My purpose is to insert the individual block name to drawing as mentioned earlier in the image in message #6.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW In the custom ipeoperties there may have already had other parameter names. The number of those items may be varied from time to time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BeKirra_0-1729221290621.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1423115i2D1E47717038C87D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BeKirra_0-1729221290621.png" alt="BeKirra_0-1729221290621.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 03:16:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13092440#M5704</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-18T03:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13093380#M5705</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468723"&gt;@BeKirra&lt;/a&gt;.&amp;nbsp; That response did not really answer all my questions, but I assume that since you quoted that part of my previous message, you want to try the multi-select list scenario.&amp;nbsp; But since I still do not know how you want each custom iProperty to be named, I decided to show you an example of the 'base name with incrementing index' naming convention route.&amp;nbsp; In this example, the 'base name' of every custom iProperty it creates/updates will be "SketchBlock".&amp;nbsp; Then that will be followed by a space, and an integer, with the integer increasing in value for each selected name in the collection, as it iterates through them.&amp;nbsp; In this example, I have replaced the iLogic 'InputListBox' function with my own tweaked version of it, which allows us to select multiple items at the same time.&amp;nbsp; The &lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.listbox.selectionmode" target="_blank" rel="noopener"&gt;selection mode&lt;/A&gt; can be changed from '&lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.selectionmode" target="_blank" rel="noopener"&gt;MultiSimple&lt;/A&gt;' to '&lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.selectionmode" target="_blank" rel="noopener"&gt;MultiExtended&lt;/A&gt;' (if you prefer using Ctrl / Shift / Arrows).&amp;nbsp; It was originally set to 'One'.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim oSBDNames As New List(Of String)
	For Each oSBD As SketchBlockDefinition In oPDoc.ComponentDefinition.SketchBlockDefinitions
		oSBDNames.Add(oSBD.Name)
	Next oSBD
	Dim oChosenNames As List(Of String) = UseListDialog("Choose SketchBlockDefinition Name To Put In Description.", _
	oSBDNames, oSBDNames(0), "SketchBlockDefinition Names", "List of SketchBlockDefinition Names")
	If oChosenNames Is Nothing OrElse oChosenNames.Count = 0 Then Return
	Dim oCProps As Inventor.PropertySet = oPDoc.PropertySets.Item(4) 'always the Custom one
	Dim sPropBaseName As String = "SketchBlock"
	Dim iNum As Integer = 0
	For Each sChosenName As String In oChosenNames
		iNum += 1
		Dim sNextPropName As String = sPropBaseName &amp;amp; " " &amp;amp; iNum.ToString
		Dim oCProp As Inventor.Property = Nothing
		Try : oCProp = oCProps.Item(sNextPropName) : Catch : End Try
		If oCProp IsNot Nothing Then
			oCProp.Value = sNextPropName
		Else 'it was not found, so try to create it
			Try : oCProp = oCProps.Add(sChosenName, sNextPropName) : Catch : End Try
		End If
	Next sChosenName
	oPDoc.Update2(True)
End Sub

Function UseListDialog(Optional Instructions As String = Nothing, _
	Optional Items As IEnumerable = Nothing, Optional DefaultValue As Object = Nothing, _
	Optional Title As String = Nothing, Optional ListName As String = Nothing) As List(Of String)
	Using oLD As New InputListBoxDialog(Title, ListName, Instructions, Items, DefaultValue)
		Dim oLB As System.Windows.Forms.ListBox = oLD.Controls.Item(0).Controls.Item(2)
		oLB.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple
		Dim oDlgResult As System.Windows.Forms.DialogResult = oLD.ShowDialog()
		Dim oSelected As List(Of String) = oLB.SelectedItems.Cast(Of String).ToList
		Return oSelected
	End Using
End Function&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>Fri, 18 Oct 2024 12:52:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13093380#M5705</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-10-18T12:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add A Block Name to iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13116775#M5706</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Yes, I missed your points.&lt;/P&gt;&lt;P&gt;Sorry I was too busy and not able to reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I really need is the names of block.&lt;/P&gt;&lt;P&gt;I don't worry about the "value" of blocks.&lt;/P&gt;&lt;P&gt;It's be much appreciated if "SketchBlock 1", "SketchBlock 2" and so on can be replaced with block names.&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BeKirra_0-1730255219553.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1427360iEC7C4AD0E5B1AD7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BeKirra_0-1730255219553.png" alt="BeKirra_0-1730255219553.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2024 02:29:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/how-to-add-a-block-name-to-iproperties/m-p/13116775#M5706</guid>
      <dc:creator>BeKirra</dc:creator>
      <dc:date>2024-10-30T02:29:18Z</dc:date>
    </item>
  </channel>
</rss>

