<?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 – Question About Multiple User Inputs in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-question-about-multiple-user-inputs/m-p/8913751#M73645</link>
    <description>&lt;P&gt;You could use "SelectEvent" to trigger the select event, and support the multiple selection. You could access API help document to get the sample code.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jul 2019 08:07:10 GMT</pubDate>
    <dc:creator>Yijiang.Cai</dc:creator>
    <dc:date>2019-07-17T08:07:10Z</dc:date>
    <item>
      <title>iLogic – Question About Multiple User Inputs</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-question-about-multiple-user-inputs/m-p/8902017#M73644</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote iLogic code for a part file that takes user input and calculates cross-sectional area, moment of inertia values (Ix and Iy), and calculates the weight per foot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is about the user input. Currently, my code allows the user to select only one surface to calculate the area, moments of inertia, and weight. Is there a way in iLogic to allow the user to select multiple surfaces? And is there a way to ask the user up front if they want to select one or more than one surface?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've posted my code below. It's somewhat long, but I wanted to give an idea of what my code currently looks like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Preliminary Setup&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;App = ThisApplication&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;doc = ThisDoc.Document&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oCD = doc.ComponentDefinition&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oBodies = oCD.SurfaceBodies&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oCommandMgr = App.CommandManager&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Dim oFace As Face&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'1: Check for Bodies&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If oBodies.Count = 0 Then&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show("Part File Must Contain a Body!", "iLogic Error Alert:", MessageBoxButtons.OK)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Exit Sub&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'2: Check for Planar Faces&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;blnPlanarFaceCheck = False&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;For Each oSurfaceBody As SurfaceBody In oBodies&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;For Each oFace In oSurfaceBody.Faces&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;blnPlanarFaceCheck = True&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;GoTo jmpFaceCheck&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Next&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Next&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;jmpFaceCheck : If blnPlanarFaceCheck = False Then&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show("There Must Be a Flat Face for Selection!", "iLogic Error Alert:", MessageBoxButtons.OK)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Exit Sub&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'3: Check To See If Sketch Is Defined In XY Plane&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Dim oSketch As PlanarSketch&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oSketch = ThisDoc.Document.ComponentDefinition.Sketches.Item(1)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If oSketch.PlanarEntity.Name &amp;lt;&amp;gt; "XY Plane" Then&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show("The Sketch Must Be Defined on the XY Plane!", "iLogic Error Alert:", MessageBoxButtons.OK)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Exit Sub&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'4: Check To See If Material Is Specified&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If ThisDoc.Document.ComponentDefinition.Material.Name = "Generic" Then&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show("The Part Has No Material Assigned!", "iLogic Error Alert:", MessageBoxButtons.OK)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Exit Sub&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'5: Select Face and Check&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;jmpFaceSelection : oFace = oCommandMgr.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select planar face to calculate area, Ix, and Iy properties")&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If oFace.Type &amp;lt;&amp;gt; ObjectTypeEnum.kFaceObject Then&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show("A Surface Face Must Be Selected!", "iLogic Error Alert:", MessageBoxButtons.OK)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;GoTo jmpFaceSelection&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Calculate Area, Ix, and Iy&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oTransaction = App.TransactionManager.StartTransaction(doc, "Inertia Calculation")&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;App.ScreenUpdating = False&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oSK = oCD.Sketches.Add(oFace)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oSK.Edit&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oCommandMgr.ControlDefinitions("SketchProjectCutEdgesCmd").Execute&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oProfile = oSK.Profiles.AddForSolid&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oRegProps = oProfile.RegionProperties&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;dArea = oRegProps.Area&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Dim adPrincipalMoments(2) As Double&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oRegProps.PrincipalMomentsofInertia(adPrincipalMoments(0), adPrincipalMoments(1), adPrincipalMoments(2))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oSK.ExitEdit&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;App.ScreenUpdating = True&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oTransaction.Abort&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Copy Values to Custom iProperties&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;iProperties.Value("Custom", "Area") = Format(dArea / 6.452, ".000") 'dividing by 6.452 converts from cm^2 to in^2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;iProperties.Value("Custom", "Ix") = Format(adPrincipalMoments(0) / 41.623, ".000") 'dividing by 41.623 converts from cm^4 to in^4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;iProperties.Value("Custom", "Iy") = Format(adPrincipalMoments(1) / 41.623, ".000") 'dividing by 41.623 converts from cm^4 to in^4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;iProperties.Value("Custom", "Mass") = Format(iProperties.Mass, ".000")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Additional Custom iProperties&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;iProperties.Value("Custom", "Material") = Format(iProperties.Material)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;iProperties.Value("Custom", "Drawn By") = Format(UCase(iProperties.Value("Summary","Author")))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'6: Check Length of Part&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If Round(iProperties.Volume / (dArea/6.452)) &amp;lt;&amp;gt; 12 Then 'dividing by 6.452 converts from cm^2 to in^2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show("The Part Has Not Been Extruded To a Depth Of 12 Inches!", "iLogic Error Alert:", MessageBoxButtons.OK)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Exit Sub&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'If There Are No Errors, Message Box Appears. Runs Through All Previous Checks Before Displaying Message Box.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;If oBodies.Count = 1 And '1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;blnPlanarFaceCheck = True And '2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oSketch.PlanarEntity.Name = "XY Plane" And '3&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ThisDoc.Document.ComponentDefinition.Material.Name &amp;lt;&amp;gt; "Generic" And '4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;oFace.Type = ObjectTypeEnum.kFaceObject And '5&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Round(iProperties.Volume / (dArea/6.452)) = 12 Then '6&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show("Calculations Made. No Errors Found.", "iLogic Message", MessageBoxButtons.OK)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Exit Sub&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;End If&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Update the Document That the Rule Is Running In&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;InventorVb.DocumentUpdate&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 18:46:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-question-about-multiple-user-inputs/m-p/8902017#M73644</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-10T18:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic – Question About Multiple User Inputs</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-question-about-multiple-user-inputs/m-p/8913751#M73645</link>
      <description>&lt;P&gt;You could use "SelectEvent" to trigger the select event, and support the multiple selection. You could access API help document to get the sample code.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 08:07:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-question-about-multiple-user-inputs/m-p/8913751#M73645</guid>
      <dc:creator>Yijiang.Cai</dc:creator>
      <dc:date>2019-07-17T08:07:10Z</dc:date>
    </item>
  </channel>
</rss>

