<?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: Measuring Area of a Surface Body in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5736619#M57630</link>
    <description>&lt;P&gt;You can obtain this information directly from the API. The attached part file has an included macro (Areas) that obtains the raw surface area for each face (in each surface body - only one body in this simple part). The code works for parts that are solids or surfaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is just the basics to show the information, you would have to handle units conversions (UnitsOfMeasure&amp;nbsp;object in the Inventor API) and writing the information to a suitable place or otherwise using the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jul 2015 00:21:06 GMT</pubDate>
    <dc:creator>nmunro</dc:creator>
    <dc:date>2015-07-23T00:21:06Z</dc:date>
    <item>
      <title>Measuring Area of a Surface Body</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5736224#M57608</link>
      <description>&lt;P&gt;I have a group of surface bodies that I need to calculate the surface area of, and I am having trouble figuring out how to do it. The iProperties-&amp;gt;Physical measurement for area shows as 0.000 mm^2, which is I assume because there are no solid bodies (just surfaces). My surfaces are complex and I haven't had much success thickening the surfaces (I can get it to work but it takes a huge amount of time that I'd rather not spend doing this).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am hoping to do is use a combination of the measure area tool and looping through all the faces of the model in order to measure the area, but I'm not sure how to do either of these things using the Inventor API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions on how to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2015 19:00:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5736224#M57608</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-22T19:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Measuring Area of a Surface Body</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5736456#M57624</link>
      <description>&lt;P&gt;So I was able to figure it out reasonable successfully, and figured I'd share the code for anybody interested. The code cycles through all the faces of each surface, then runs the Measure Area command. I couldn't figure out how to read the value from the text box that pops up (and Application.MeasureTools doesn't have a GetArea function) so I need to copy the area into an input box manually. This then uses a mass/ sq.m density to calculate the mass of the surface and plug it into the Mass property of the part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has suggestions on how to copy the area from the text box (or use another code snippet to measure the area) into a variable, that would be great!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub SurfaceMeasurement()&lt;/P&gt;&lt;P&gt;'Check all referenced docs&lt;BR /&gt;Dim oDoc As Inventor.Document&lt;BR /&gt;Dim oSurfaceBodies As WorkSurface&lt;BR /&gt;Dim oFace As Face&lt;BR /&gt;Dim oControlDef As ControlDefinition&lt;BR /&gt;Dim faceCollection As ObjectCollection&lt;BR /&gt;Dim area As Double&lt;BR /&gt;Dim density As Double&lt;BR /&gt;Dim mass As Double&lt;BR /&gt;&lt;BR /&gt;mass = 0&lt;BR /&gt;&lt;BR /&gt;Set oDoc = ThisApplication.ActiveDocument&lt;BR /&gt;oDoc.SelectSet.Clear&lt;BR /&gt;&lt;BR /&gt;Set faceCollection = ThisApplication.TransientObjects.CreateObjectCollection(Null)&lt;BR /&gt;&lt;BR /&gt;'set surface bodies visibility&lt;BR /&gt;For Each oSurfaceBodies In oDoc.ComponentDefinition.WorkSurfaces&lt;BR /&gt;'oSurfaceBodies.Visible = wfBoolean&lt;BR /&gt;For Each oFace In oSurfaceBodies.SurfaceBodies.Item(1).Faces&lt;BR /&gt;faceCollection.Add oFace&lt;BR /&gt;' oDoc.SelectSet.Select oFace&lt;BR /&gt;Next&lt;BR /&gt;oDoc.SelectSet.SelectMultiple faceCollection&lt;BR /&gt;Set oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppMeasureAreaCmd")&lt;BR /&gt;oControlDef.Execute&lt;BR /&gt;area = InputBox("Please enter the area (mm^2): ", "Area")&lt;BR /&gt;density = InputBox("Please enter the mass per m^2: ", "Density")&lt;BR /&gt;mass = mass + area * density * 0.000001&lt;BR /&gt;Next&lt;BR /&gt;MsgBox "The mass is " &amp;amp; CStr(mass) &amp;amp; " kg."&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;oDoc.ComponentDefinition.MassProperties.mass = mass&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2015 21:02:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5736456#M57624</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-22T21:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Measuring Area of a Surface Body</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5736619#M57630</link>
      <description>&lt;P&gt;You can obtain this information directly from the API. The attached part file has an included macro (Areas) that obtains the raw surface area for each face (in each surface body - only one body in this simple part). The code works for parts that are solids or surfaces.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is just the basics to show the information, you would have to handle units conversions (UnitsOfMeasure&amp;nbsp;object in the Inventor API) and writing the information to a suitable place or otherwise using the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 00:21:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5736619#M57630</guid>
      <dc:creator>nmunro</dc:creator>
      <dc:date>2015-07-23T00:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Measuring Area of a Surface Body</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5739610#M57655</link>
      <description>&lt;P&gt;Thanks for the assistance. The Evaluator function allows reading of the face areas without having to type it in like my first attempt was!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've copied the code if anyone wants to look at it. It uses the area to determine and assign a mass based on the surface area density that you assign through an input box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sub SurfaceMeasurement()&lt;/P&gt;&lt;P&gt;'Check all referenced docs&lt;BR /&gt;Dim oDoc As Inventor.Document&lt;BR /&gt;Dim oSurfaceBodies As WorkSurface&lt;BR /&gt;Dim oSurfaceBody As SurfaceBody&lt;BR /&gt;Dim oFace As Face&lt;BR /&gt;Dim density As Double&lt;BR /&gt;Dim mass As Double&lt;BR /&gt;Dim allArea As Double&lt;BR /&gt;&lt;BR /&gt;mass = 0&lt;BR /&gt;allArea = 0&lt;BR /&gt;tcount = 0&lt;BR /&gt;Set oDoc = ThisApplication.ActiveDocument&lt;BR /&gt;oDoc.SelectSet.Clear&lt;BR /&gt;&lt;BR /&gt;'set surface bodies visibility&lt;BR /&gt;For Each oSurfaceBodies In oDoc.ComponentDefinition.WorkSurfaces&lt;BR /&gt;For Each oSurfaceBody In oSurfaceBodies.SurfaceBodies&lt;/P&gt;&lt;P&gt;For Each oFace In oSurfaceBody.Faces&lt;/P&gt;&lt;P&gt;allArea = allArea + oFace.Evaluator.area * 100&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;Next&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;density = InputBox("Please enter the mass per m^2: ", "Density", 2.477)&lt;BR /&gt;mass = allArea * density * 0.000001&lt;BR /&gt;MsgBox "The mass is " &amp;amp; CStr(mass) &amp;amp; " kg."&lt;BR /&gt;&lt;BR /&gt;oDoc.ComponentDefinition.MassProperties.mass = mass&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2015 16:47:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/measuring-area-of-a-surface-body/m-p/5739610#M57655</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-24T16:47:33Z</dc:date>
    </item>
  </channel>
</rss>

