<?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 How to convert PolygonZM to Polygon in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1076397#M20344</link>
    <description>&lt;P&gt;I am writing an add-in that calculates the cost for a spray job.&lt;/P&gt;&lt;P&gt;This next block of code works perfectly for adding a polygon feature to my objClasses list,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;But only when the feature's shape is "Polygon", not "Polygon ZM" which is the default shape for the sprayer's control to export.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I would like to know is there a way to modify my code slightly to include a Polygon ZM feature, or will I have to edit the Map and order to disable the Z and M axis.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IMap focusMap = ArcMap.Document.FocusMap;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;IEnumFeature enumFeature = focusMap.FeatureSelection as IEnumFeature;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;enumFeature?.Reset();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (enumFeature is IEnumFeatureSetup enumFeatSetup)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;enumFeatSetup.AllFields = true;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;double totalArea = 0;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;int featCount = 0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;try&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;// List of Object Classes to run the Calculate Field tool on&lt;BR /&gt;&lt;STRONG&gt;List&amp;lt;IObjectClass&amp;gt; objClasses = new List&amp;lt;IObjectClass&amp;gt;();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// step through feature selection and add to Object Classes list if they're a polygon.&lt;BR /&gt;&lt;STRONG&gt;IFeature feature = enumFeature?.Next();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;while (feature != null)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;currentFeatureClassAlias = feature.Class.AliasName;&lt;/STRONG&gt; // keeping track of this for error messages.&lt;/P&gt;&lt;P&gt;// Check if a feature is a polygon and that its object class is not already added to the objClasses list.&lt;BR /&gt;// If no layer is specified, add the feature's object class to the objClasses list if the previous two conditions are met.&lt;BR /&gt;// If a layer has been specified, check that the feature is a member of that layer before adding its object class to the list.&lt;BR /&gt;&lt;STRONG&gt;if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon &amp;amp;&amp;amp; !objClasses.Contains(feature.Class) &amp;amp;&amp;amp; (feature.Class.AliasName == onLayer?.Name || onLayer == null))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;objClasses.Add(feature.Class);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;feature = enumFeature.Next();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// Break out if no compatible features are selected.&lt;BR /&gt;&lt;STRONG&gt;if (objClasses.Count &amp;lt; 1)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show($"No polygon features selected from {onLayer?.Name} layer. Cannot calculate area.");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rconrad_0-1625678904350.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/17895iAB205B53BFFD4D60/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rconrad_0-1625678904350.png" alt="Rconrad_0-1625678904350.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rconrad_2-1625679436843.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/17897i845D270DDAFEA451/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rconrad_2-1625679436843.png" alt="Rconrad_2-1625679436843.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would greatly appreciate any help with this. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jul 2021 17:50:19 GMT</pubDate>
    <dc:creator>Rconrad</dc:creator>
    <dc:date>2021-07-07T17:50:19Z</dc:date>
    <item>
      <title>How to convert PolygonZM to Polygon</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1076397#M20344</link>
      <description>&lt;P&gt;I am writing an add-in that calculates the cost for a spray job.&lt;/P&gt;&lt;P&gt;This next block of code works perfectly for adding a polygon feature to my objClasses list,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;But only when the feature's shape is "Polygon", not "Polygon ZM" which is the default shape for the sprayer's control to export.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I would like to know is there a way to modify my code slightly to include a Polygon ZM feature, or will I have to edit the Map and order to disable the Z and M axis.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IMap focusMap = ArcMap.Document.FocusMap;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;IEnumFeature enumFeature = focusMap.FeatureSelection as IEnumFeature;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;enumFeature?.Reset();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (enumFeature is IEnumFeatureSetup enumFeatSetup)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;enumFeatSetup.AllFields = true;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;double totalArea = 0;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;int featCount = 0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;try&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;// List of Object Classes to run the Calculate Field tool on&lt;BR /&gt;&lt;STRONG&gt;List&amp;lt;IObjectClass&amp;gt; objClasses = new List&amp;lt;IObjectClass&amp;gt;();&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// step through feature selection and add to Object Classes list if they're a polygon.&lt;BR /&gt;&lt;STRONG&gt;IFeature feature = enumFeature?.Next();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;while (feature != null)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;currentFeatureClassAlias = feature.Class.AliasName;&lt;/STRONG&gt; // keeping track of this for error messages.&lt;/P&gt;&lt;P&gt;// Check if a feature is a polygon and that its object class is not already added to the objClasses list.&lt;BR /&gt;// If no layer is specified, add the feature's object class to the objClasses list if the previous two conditions are met.&lt;BR /&gt;// If a layer has been specified, check that the feature is a member of that layer before adding its object class to the list.&lt;BR /&gt;&lt;STRONG&gt;if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon &amp;amp;&amp;amp; !objClasses.Contains(feature.Class) &amp;amp;&amp;amp; (feature.Class.AliasName == onLayer?.Name || onLayer == null))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;objClasses.Add(feature.Class);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;feature = enumFeature.Next();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;// Break out if no compatible features are selected.&lt;BR /&gt;&lt;STRONG&gt;if (objClasses.Count &amp;lt; 1)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;MessageBox.Show($"No polygon features selected from {onLayer?.Name} layer. Cannot calculate area.");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rconrad_0-1625678904350.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/17895iAB205B53BFFD4D60/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rconrad_0-1625678904350.png" alt="Rconrad_0-1625678904350.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rconrad_2-1625679436843.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/17897i845D270DDAFEA451/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rconrad_2-1625679436843.png" alt="Rconrad_2-1625679436843.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would greatly appreciate any help with this. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 17:50:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1076397#M20344</guid>
      <dc:creator>Rconrad</dc:creator>
      <dc:date>2021-07-07T17:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert PolygonZM to Polygon</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1076614#M20345</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your code works fine on ArcGIS 10.3 if omit part of condition checking:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon &amp;amp;&amp;amp; !objClasses.Contains(feature.Class))
                {
                    objClasses.Add(feature.Class);
                }&lt;/LI-CODE&gt;&lt;P&gt;So issue is with layer name and not with geometry type&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 06:25:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1076614#M20345</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-07-08T06:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert PolygonZM to Polygon</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1076977#M20346</link>
      <description>&lt;P&gt;That's exactly what I did and it worked just as needed. Don't know why I thought I needed to convert it. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 20:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1076977#M20346</guid>
      <dc:creator>Rconrad</dc:creator>
      <dc:date>2021-07-08T20:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert PolygonZM to Polygon</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1078742#M20349</link>
      <description>&lt;P&gt;A side note when posting code in a question, please use the syntax highlighter, it makes your code much more readable. You might need to click on the ... button to expand the menu and see the &amp;lt;/&amp;gt; button.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 16:06:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-convert-polygonzm-to-polygon/m-p/1078742#M20349</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-07-14T16:06:18Z</dc:date>
    </item>
  </channel>
</rss>

