<?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 Betreff: Custom iProperty is type Number; needs to write to type string in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10735581#M43912</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, forgot to say the parameter &lt;STRONG&gt;value&lt;/STRONG&gt; is the string you want to compare with "Estimated"&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If oMyParameter.Item("ActualOrEstimated").value = "Estimated" Then&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 13:53:56 GMT</pubDate>
    <dc:creator>Ralf_Krieg</dc:creator>
    <dc:date>2021-11-04T13:53:56Z</dc:date>
    <item>
      <title>Custom iProperty is type Number; needs to write to type string</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10734096#M43909</link>
      <description>&lt;LI-CODE lang="general"&gt;Our new ERP system requires a custom iproperty called "gss_rm_qty" for raw material measurement in string format.


I would like our users to be able to choose whether this value is actual face area or bounding box size (basically length x width)... I've already put together the code to create these custom iproperties (SheetMetalExtentsArea vs SheetMetalActualArea below), however, they are "number" type. Which is preventing me from writing the choice directly to "gss_rm_qty" with the error:

         Overload resolution failed because no Public '=' can be called with these arguments:
         'Public Shared Operator =(a As String, b As String) As Boolean':
         Argument matching parameter 'a' cannot convert from '__ComObject' to 'String'.


Below is the part of the code that is not working...


oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
	'Setting a userParameter as text parameter
Try
	otester = oMyParameter.Item("ActualOrEstimated")
Catch
	oAreaType = oMyParameter.AddByValue("ActualOrEstimated", "Estimated", UnitsTypeEnum.kTextUnits) 
	'make parameter a multivalue list parameter
	MultiValue.SetList("ActualOrEstimated", "Estimated", "Actual")
End Try

If oMyParameter.Item("ActualOrEstimated") = "Estimated" Then
	oCustomProps.Item("gss_rm_qty") = Convert.ToString(oCustomProps.Item("SheetMetalExtentsArea").Value)
Else
	oCustomProps.Item("gss_rm_qty") = Convert.ToString(oCustomProps.Item("SheetMetalActualArea").Value)
End If​




I tried to use CStr() &amp;amp; Convert.ToString()in but it doesn't seem to work either. Maybe I'm not formatting them correctly, idk.

oCustomProps.Item("gss_rm_qty") = Convert.ToString(oCustomProps.Item("SheetMetalActualArea").Value)

oCustomProps.Item("gss_rm_qty") = CStr(oCustomProps.Item("SheetMetalActualArea").Value)


Any help to get this formatted correctly to output would be appreciated. Thanks!&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Nov 2021 23:44:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10734096#M43909</guid>
      <dc:creator>jwitt1983</dc:creator>
      <dc:date>2021-11-03T23:44:19Z</dc:date>
    </item>
    <item>
      <title>Betreff: Custom iProperty is type Number; needs to write to type string</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10734903#M43910</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AFAIK, Inventor defines the data type of an iProp by itself. I think your problem is, that you try to assign a property value to another property, not to another propertys value.&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If oMyParameter.Item("ActualOrEstimated") = "Estimated" Then
	oCustomProps.Item("gss_rm_qty").value = Convert.ToString(oCustomProps.Item("SheetMetalExtentsArea").Value)
Else
	oCustomProps.Item("gss_rm_qty").value = Convert.ToString(oCustomProps.Item("SheetMetalActualArea").Value)
End If​
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Nov 2021 09:17:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10734903#M43910</guid>
      <dc:creator>Ralf_Krieg</dc:creator>
      <dc:date>2021-11-04T09:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Custom iProperty is type Number; needs to write to type string</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10735479#M43911</link>
      <description>&lt;P&gt;I tried your suggestion of adding .Value to the "gss_rm_qty" property... still same error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also tried your suggestion along with using CStr() instead of Convert.ToString()... I believe these are the same but thought it would be worth a shot either way, still same error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Overload resolution failed because no Public '=' can be called with these arguments:
         'Public Shared Operator =(a As String, b As String) As Boolean':
         Argument matching parameter 'a' cannot convert from '__ComObject' to 'String'.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 13:19:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10735479#M43911</guid>
      <dc:creator>jwitt1983</dc:creator>
      <dc:date>2021-11-04T13:19:10Z</dc:date>
    </item>
    <item>
      <title>Betreff: Custom iProperty is type Number; needs to write to type string</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10735581#M43912</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, forgot to say the parameter &lt;STRONG&gt;value&lt;/STRONG&gt; is the string you want to compare with "Estimated"&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If oMyParameter.Item("ActualOrEstimated").value = "Estimated" Then&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 13:53:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10735581#M43912</guid>
      <dc:creator>Ralf_Krieg</dc:creator>
      <dc:date>2021-11-04T13:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Custom iProperty is type Number; needs to write to type string</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10736111#M43913</link>
      <description>&lt;P&gt;Your code fragment can't be tested, but try the following modified and commented code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'Define oMyParameter type explicitly for better intellisense
Dim oMyParameter As UserParameters = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
'Setting a userParameter as text parameter
Try
	Dim otester = oMyParameter.Item("ActualOrEstimated")
Catch
	oAreaType = oMyParameter.AddByValue("ActualOrEstimated", "Estimated", UnitsTypeEnum.kTextUnits)
	'make parameter a multivalue list parameter
	MultiValue.SetList("ActualOrEstimated", "Estimated", "Actual")
End Try


'If oMyParameter.Item("ActualOrEstimated").Value.ToString() = "Estimated" Then
'oCustomProps.Item("gss_rm_qty") = Convert.ToString(oCustomProps.Item("SheetMetalExtentsArea").Value)
'Else
'oCustomProps.Item("gss_rm_qty") = Convert.ToString(oCustomProps.Item("SheetMetalActualArea").Value)
'End If

Dim doubleValue As Double
If oMyParameter.Item("ActualOrEstimated").Value.ToString() = "Estimated" Then
	doubleValue = oCustomProps.Item("SheetMetalExtentsArea").Value
Else
	doubleValue= oCustomProps.Item("SheetMetalActualArea").Value
End If

'Use string.Format function with possible formatting 
'For example {0:N3} =&amp;gt; converst value to string rounded to 3 decimal places
oCustomProps.Item("gss_rm_qty").Value = String.Format("{0:N3}", doubleValue)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 17:07:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/custom-iproperty-is-type-number-needs-to-write-to-type-string/m-p/10736111#M43913</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2021-11-04T17:07:34Z</dc:date>
    </item>
  </channel>
</rss>

