<?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: assembly physical properties to clipboard in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232218#M157497</link>
    <description>&lt;P&gt;You've picked a very difficult task to learn coding.&lt;/P&gt;&lt;P&gt;I can't find the command of the "Clipboard" button.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2023 14:46:17 GMT</pubDate>
    <dc:creator>Frederick_Law</dc:creator>
    <dc:date>2023-09-11T14:46:17Z</dc:date>
    <item>
      <title>assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232110#M157495</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a total beginner of iLogic with no previous programming experience. But feel so excited when I discovered this in Inventor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to achieve is to have the physical properties updated and copied to clipboard as soon as the properties change. It could be that I move a component in an assembly that effects the center of gravity and the inertia properties.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help me with the code for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR&lt;BR /&gt;Joel&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 14:04:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232110#M157495</guid>
      <dc:creator>joel_wennerstrand</dc:creator>
      <dc:date>2023-09-11T14:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232218#M157497</link>
      <description>&lt;P&gt;You've picked a very difficult task to learn coding.&lt;/P&gt;&lt;P&gt;I can't find the command of the "Clipboard" button.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 14:46:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232218#M157497</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-09-11T14:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232586#M157509</link>
      <description>&lt;P&gt;I agree.&amp;nbsp; I had also tried to find the command behind that button before, but was not able to.&amp;nbsp; We do know the command behind the UPDATE button ("AppUpdateMassPropertiesCmd"), but not the Clipboard button.&amp;nbsp; That command does not appear to have been exposed to the iLogic or Inventor API system yet either.&amp;nbsp; However, we do have access to pretty much all the same data through the Inventor API system, so could most likely replicate what that button does by code.&amp;nbsp; Writing the code for that task would be a real pain though, and would likely require quite a lot of code.&amp;nbsp; We have access to most of the data you see on that Physical Properties tab through the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-MassProperties" target="_blank" rel="noopener"&gt;MassProperties&lt;/A&gt; API object.&amp;nbsp; And we can get access to that MassProperties object within the ComponentDefinition of PartDocuments (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=PartComponentDefinition_MassProperties" target="_blank" rel="noopener"&gt;PartComponentDefinition.MassProperties&lt;/A&gt;), AssemblyDocuments (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=AssemblyComponentDefinition_MassProperties" target="_blank" rel="noopener"&gt;AssemblyComponentDefinition.MassProperties&lt;/A&gt;), and through assembly components (&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ComponentOccurrence_MassProperties" target="_blank" rel="noopener"&gt;ComponentOccurrence.MassProperties&lt;/A&gt;), and a few other specialty types.&amp;nbsp; Once you have a reference to that MassProperties object assigned to a variable within your code, you can begin extracting all the data you require from it, using its various Methods &amp;amp; Properties.&amp;nbsp; But keep in mind that the data you get from those methods &amp;amp; properties will be in 'database units' instead of 'document units' (if they are different).&amp;nbsp; So, you may need to convert the units of the values as needed, to see the values in the units you want.&amp;nbsp; Then as you are extracting the data you want, you can build a large String (text) that contains textual sentences which include the data, and format it as you would like to see it, similar to what you see when you paste that copied data into a Microsoft Word document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The steps of copying the data to the system clipboard, and/or retrieving that data from the Clipboard, is likely the simplest steps of the whole process.&amp;nbsp; Below is an extremely simple example of pasting text type data to the Clipboard, then retrieving it again, then showing the retrieved data in a MessageBox.&amp;nbsp; You may notice that it does not try to correct my use of a capital E in the word Copied.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Clipboard.SetText("Text 2 B CopiEd!", TextDataFormat.Rtf)
sCopiedText = Clipboard.GetText(TextDataFormat.Rtf)
MessageBox.Show("The following text was copied to the Clipboard:  " _
&amp;amp; vbCrLf &amp;amp; sCopiedText, "Retrieved From System Clipboard")&lt;/LI-CODE&gt;
&lt;P data-unlink="true"&gt;I am specifying RTF format, because that is the specific format being used by the Clipboard button in the Physical Properties tab.&amp;nbsp; Here is a link to the online help page&amp;nbsp; which mentions that.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-877564AC-78CE-4216-9913-003A2DE8D698" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-877564AC-78CE-4216-9913-003A2DE8D698&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 17:28:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232586#M157509</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-09-11T17:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232611#M157512</link>
      <description>&lt;P&gt;I was thinking to use keyboard keys to tab to "Clipboard" then "click" it.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 17:42:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232611#M157512</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-09-11T17:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232694#M157519</link>
      <description>&lt;P&gt;Good idea, but possibly a bit unstable.&amp;nbsp; Here is my attempt at doing that by code.&amp;nbsp; The first 3 lines seem to work as planned, but the following lines were not working as planned.&amp;nbsp; They seem to be getting odd (unexpected) data.&amp;nbsp; But if I just run the rule with the first 3 lines, it seems to copy the right data to the Clipboard, then I can open a new, empty Microsoft Word document, and paste it in there, as planned.&amp;nbsp; Not sure why the clipboard retrieval step is not working right.&amp;nbsp; May be a timing related issue.&amp;nbsp; It may need to process a while longer before trying to get the data from the clipboard or something.&amp;nbsp; Might need to use a loop to wait a bit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;ThisApplication.CommandManager.ControlDefinitions.Item("AppiPropertiesWrapperCmd").Execute2(False)
System.Windows.Forms.SendKeys.SendWait("{RIGHT 6}{TAB 3}{ENTER}{TAB}{ENTER}{ESC}")
ThisApplication.UserInterfaceManager.DoEvents()
'Dim sMassPropsData As String = System.Windows.Forms.Clipboard.GetText(System.Windows.Forms.TextDataFormat.Rtf)
'Logger.Info(sMassPropsData)
'System.IO.File.WriteAllText("C:\Temp\MassProperties.txt", sMassPropsData, System.Text.Encoding.Unicode)
'Process.Start("notepad.exe", "C:\Temp\MassProperties.txt")&lt;/LI-CODE&gt;
&lt;P&gt;Edit:&amp;nbsp; Oh, and by the way...if you use those first three lines on a document that does not have any model mass yet, the UPDATE button will not be available, so the sequence of 3 tabs would go straight to the CLIPBOARD button, instead of the UPDATE button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 18:22:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232694#M157519</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2023-09-11T18:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232704#M157521</link>
      <description>&lt;P&gt;Probably faster to get the data and send it to clipboard.&lt;/P&gt;&lt;P&gt;This is what's in clipboard:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Physical Properties for Frame-ASSY-MS
General Properties:
	Material:	{}
	Density:	0.000 g/cm^3
	Mass:	N/A
	Area:	N/A
	Volume:	N/A
Center of Gravity:
	X:	N/A
	Y:	N/A
	Z:	N/A
Mass Moments of Inertia with respect to Center of Gravity(Calculated using negative integral)
	Ixx        	N/A
	Iyx Iyy    	N/A	N/A
	Izx Izy Izz	N/A	N/A	N/A
Mass Moments of Inertia with respect to Global(Calculated using negative integral)
	Ixx        	N/A
	Iyx Iyy    	N/A	N/A
	Izx Izy Izz	N/A	N/A	N/A
Principal Moments of Inertia with respect to Center of Gravity
	I1:	N/A
	I2:	N/A
	I3:	N/A
Rotation from Global to Principal
	Rx:	N/A
	Ry:	N/A
	Rz:	N/A&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 18:26:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12232704#M157521</guid>
      <dc:creator>Frederick_Law</dc:creator>
      <dc:date>2023-09-11T18:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12233121#M157559</link>
      <description>&lt;P&gt;You could recreate the code. Here is a start but it is finished.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Dim doc As PartDocument = ThisDoc.Document
Dim uom = doc.UnitsOfMeasure
Dim nl = System.Environment.NewLine
Dim tab As Char = "\u0009"

Dim material = doc.ComponentDefinition.Material
Dim massProps = doc.ComponentDefinition.MassProperties
Dim Ixx, Iyy, Izz, Ixy, Iyz, Ixz
massProps.XYZMomentsOfInertia(Ixx, Iyy, Izz, Ixy, Iyz, Ixz)

Dim I1, I2, I3
massProps.PrincipalMomentsOfInertia(I1, I2, I3)
Dim Rx, Ry, Rz
massProps.RotationToPrincipal(Rx, Ry, Rz)

Dim txt As New StringBuilder()
txt.AppendFormat("Physical Properties for {0}{1}", doc.DisplayName, nl)

txt.AppendLine("General Properties:")
txt.AppendFormat("{1}Material:{1}{2}{0}", nl, vbTab, material.Name)
txt.AppendFormat("{1}Density:{1}{2}{0}", nl, vbTab, material.Density)
txt.AppendFormat("{1}Mass:{1}{1}{2}{0}", nl, vbTab, uom.ConvertUnits(massProps.Mass, UnitsTypeEnum.kDatabaseMassUnits, UnitsTypeEnum.kDefaultDisplayMassUnits))
txt.AppendFormat("{1}Area:{1}{1}{2}{0}", nl, vbTab, massProps.Area)
txt.AppendFormat("{1}Volume:{1}{1}{2}{0}", nl, vbTab, massProps.Volume)

txt.AppendLine("Center of Gravity:")
txt.AppendFormat("{1}X:{1}{1}{2}{0}", nl, vbTab, massProps.CenterOfMass.X)
txt.AppendFormat("{1}Y:{1}{1}{2}{0}", nl, vbTab, massProps.CenterOfMass.Y)
txt.AppendFormat("{1}Z:{1}{1}{2}{0}", nl, vbTab, massProps.CenterOfMass.Z)

txt.AppendLine("Mass Moments of Inertia with respect to ???????? (Calculated using negative integral)")
txt.AppendFormat("{1}Ixx:{1}{1}{2}{0}", nl, vbTab, Ixx)
txt.AppendFormat("{1}Ixy Iyy:{1}{2} {3}{0}", nl, vbTab, Ixy, Iyy)
txt.AppendFormat("{1}Ixz Iyz Izz:{1}{2} {3} {4}{0}", nl, vbTab, Ixz, Iyz, Izz)

txt.AppendLine("Principal Moments of Inertia with respect to Center of Gravity:")
txt.AppendFormat("{1}I1:{1}{1}{2}{0}", nl, vbTab, I1)
txt.AppendFormat("{1}I2:{1}{1}{2}{0}", nl, vbTab, I2)
txt.AppendFormat("{1}I3:{1}{1}{2}{0}", nl, vbTab, I3)

txt.AppendLine("Rotation from Global to Principal:")
txt.AppendFormat("{1}R1:{1}{1}{2}{0}", nl, vbTab, Rx)
txt.AppendFormat("{1}R2:{1}{1}{2}{0}", nl, vbTab, Ry)
txt.AppendFormat("{1}R3:{1}{1}{2}{0}", nl, vbTab, Rz)


Clipboard.SetText(txt.ToString(), TextDataFormat.Text)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 11 Sep 2023 21:26:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12233121#M157559</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2023-09-11T21:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: assembly physical properties to clipboard</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12234621#M157599</link>
      <description>&lt;P&gt;Thank you for all the great suggestions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution with this code worked just the way I wanted. thanks again.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ThisApplication.CommandManager.ControlDefinitions.Item("AppiPropertiesWrapperCmd").Execute2(False)
System.Windows.Forms.SendKeys.SendWait("{RIGHT 6}{TAB 3}{ENTER}{TAB}{ENTER}{ESC}")
ThisApplication.UserInterfaceManager.DoEvents()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 12:41:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/assembly-physical-properties-to-clipboard/m-p/12234621#M157599</guid>
      <dc:creator>joel_wennerstrand</dc:creator>
      <dc:date>2023-09-12T12:41:47Z</dc:date>
    </item>
  </channel>
</rss>

