1 Reply Latest reply on Feb 26, 2014 11:39 AM by John Watson

    Cross-Sectional Area in a Macro

    John Watson

      Hi,

       

      I'm experienced in programming but relatively new to the SW API. I'm trying to write a macro to perform an area analysis on a part; it should take sections stacked in the X direction but at various angles and write the area of each cross section to a text (.csv) file. I've attached an example body and a macro taking the sections I mean.

       

      The two methods I know for doing this by hand are:

       

      - using a series of Section Views and the Measure tool on the sectioned face(s)

      - creating a Reference Plane and an intersection sketch, then using Section Properties to get the total area of that sketch

       

      I'm having trouble implementing these in code, however. In the first case I'm stuck on selecting the section face(s) to apply Measure.Area, and in the other I can't find any way to call Section Properties from the API.

       

      Any tips or advice would be welcome, but I'm especially wondering if there's a more macro-oriented method to accomplish this.

       

      Thanks,

       

      John

        • Re: Cross-Sectional Area in a Macro
          John Watson

          Well, I was able to do this using the Section Properties. It turns out you can call it and get the area in VBA with

           

                      vSectionProp = swModelExt.GetSectionProperties((swSelObj))

                      area = vSectionProp(1)

           

          You need to convert the selected sketch to an object first though.