<?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: Drawing rectangles and markers with vba in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714992#M19057</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I could already finish a lot of my code. At the moment it does exactly what I want. Just need to find out, how to edit fill-color and frame-color of my new rectangles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp; 
// getting Width, Height and Number of rectangles from form

Dim pMXDoc As IMxDocument
&amp;nbsp; Dim pEnv As IEnvelope
&amp;nbsp; Dim pGraCont As IGraphicsContainer
&amp;nbsp; Dim pRubberEnv As IRubberBand
&amp;nbsp; Dim pElem As IElement

&amp;nbsp; ' DIM Coordinates
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim EnvXMin As Double
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim EnvYMin As Double

&amp;nbsp;&amp;nbsp;&amp;nbsp; EnvXMin = 425419
&amp;nbsp;&amp;nbsp;&amp;nbsp; EnvYMin = 6011500

&amp;nbsp; ' QI for the MXDocument interface
&amp;nbsp; Set pMXDoc = ThisDocument
&amp;nbsp; 
&amp;nbsp; ' QI for the IGraphicsContainerSelect interface on the document's activeview
&amp;nbsp; Set pGraCont = pMXDoc.ActiveView
&amp;nbsp; 'create new Envelope
&amp;nbsp; Set pEnv = New Envelope
&amp;nbsp; pEnv.YMin = EnvYMin
&amp;nbsp; pEnv.XMin = EnvXMin
&amp;nbsp; pEnv.Height = EnvHeight
&amp;nbsp; pEnv.Width = EnvWidth
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 1 To Numbers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Create a new EnvelopeElement and set its Geometry
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pElem = New RectangleElement
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pElem.geometry = pEnv
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Add the new element at Z order zero
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pGraCont.AddElement pElem, 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Generate Offset for next rectangle
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pEnv.Offset (EnvWidth / 2), 0

&amp;nbsp;&amp;nbsp;&amp;nbsp; Next i
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; ' Refresh the activeview
&amp;nbsp; pMXDoc.ActiveView.Refresh&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 06:37:02 GMT</pubDate>
    <dc:creator>FlorianSchulze</dc:creator>
    <dc:date>2021-12-12T06:37:02Z</dc:date>
    <item>
      <title>Drawing rectangles and markers with vba</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714988#M19053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I hat little contact to VBA in ArcGis during my study, that`s why I am wrinting here right now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the moment I try to plan some flightlines for a project of mine. Therefore, I use the "draw rectangle" tool to generate the flightlines (stipes for a sensor). Then I use the properties for exact locating them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Because I have to do this for a lot of flightlines, I thought of using little VBA to automate parts of this process. But beginning seems to be very hard. I even dont really know where to start. So my question - what is the object i have to use for drawing rectangles and markers? Is there an example code available using these objects?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope, you understand my question, as my english is very poor...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Geo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jun 2011 13:07:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714988#M19053</guid>
      <dc:creator>FlorianSchulze</dc:creator>
      <dc:date>2011-06-07T13:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing rectangles and markers with vba</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714989#M19054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as there are still no answers to my questions, I hope to get some help with a code-fragment I already found. This code "draws" a rectangle at a position where I click with my mouse. I think it might just be a little editing that this code does what I need. Instead of clicking with the mouse, the rectangle has to be drawn with given width, Length and Position. Maybe someone can show me, what has to be changed. Here is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; Dim pMXDoc As IMxDocument
&amp;nbsp; Dim pEnv As IEnvelope
&amp;nbsp; Dim pGraCont As IGraphicsContainer
&amp;nbsp; Dim pRubberEnv As IRubberBand
&amp;nbsp; Dim pElem As IElement
&amp;nbsp; 
&amp;nbsp; ' QI for the MXDocument interface
&amp;nbsp; Set pMXDoc = ThisDocument
&amp;nbsp; 
&amp;nbsp; ' QI for the IGraphicsContainerSelect interface on the document's activeview
&amp;nbsp; Set pGraCont = pMXDoc.ActiveView
&amp;nbsp; 
&amp;nbsp; ' Create a new RubberEnvelope
&amp;nbsp; Set pRubberEnv = New RubberEnvelope
&amp;nbsp; ' Return a new Envelope from the tracker object using TrackNew
&amp;nbsp; Set pEnv = pRubberEnv.TrackNew(pMXDoc.ActiveView.screenDisplay, Nothing)
&amp;nbsp; ' Create a new EnvelopeElement and set its Geometry
&amp;nbsp; Set pElem = New RectangleElement
&amp;nbsp; pElem.geometry = pEnv
&amp;nbsp; 
&amp;nbsp; 'Add the new element at Z order zero
&amp;nbsp; pGraCont.AddElement pElem, 0

&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Refresh the activeview
&amp;nbsp; pMXDoc.ActiveView.Refresh

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope you can help me (please)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours Geo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:36:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714989#M19054</guid>
      <dc:creator>FlorianSchulze</dc:creator>
      <dc:date>2021-12-12T06:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing rectangles and markers with vba</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714990#M19055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It is difficult to provide any direction because it is not clear what you mean by drawing rectangles.&amp;nbsp; The code sample provided shows how to add rectangle elements to the graphics layer of a map or page layout.&amp;nbsp; This only persist in the mxd.&amp;nbsp; Usually people want to store the data in a database or something.&amp;nbsp; You can also draw directly to the activeview, it all depends on what you want the end result to be.&amp;nbsp; Perhaps if you described how you go about doing in through the interface, it would provide more information.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jun 2011 17:57:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714990#M19055</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2011-06-10T17:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing rectangles and markers with vba</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714991#M19056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Agray1,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you for your answer. At the moment it is enough, when I am able to draw the rectangles to the grafic layer, because I have to rotate and adjust them in a following step - and I know how to do this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore the missing information for me is, how to make fixed values for width, length and position of my rectangle. I dont want to use my mouse.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you already mentioned, I can also draw at the active view, but I have to avow, that I don`t know, how to rotate and move such rectangles in a following step. I would be very thankful if you or someone else could help me to solve my problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours Geo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 05:54:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714991#M19056</guid>
      <dc:creator>FlorianSchulze</dc:creator>
      <dc:date>2011-06-14T05:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing rectangles and markers with vba</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714992#M19057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I could already finish a lot of my code. At the moment it does exactly what I want. Just need to find out, how to edit fill-color and frame-color of my new rectangles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp; 
// getting Width, Height and Number of rectangles from form

Dim pMXDoc As IMxDocument
&amp;nbsp; Dim pEnv As IEnvelope
&amp;nbsp; Dim pGraCont As IGraphicsContainer
&amp;nbsp; Dim pRubberEnv As IRubberBand
&amp;nbsp; Dim pElem As IElement

&amp;nbsp; ' DIM Coordinates
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim EnvXMin As Double
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim EnvYMin As Double

&amp;nbsp;&amp;nbsp;&amp;nbsp; EnvXMin = 425419
&amp;nbsp;&amp;nbsp;&amp;nbsp; EnvYMin = 6011500

&amp;nbsp; ' QI for the MXDocument interface
&amp;nbsp; Set pMXDoc = ThisDocument
&amp;nbsp; 
&amp;nbsp; ' QI for the IGraphicsContainerSelect interface on the document's activeview
&amp;nbsp; Set pGraCont = pMXDoc.ActiveView
&amp;nbsp; 'create new Envelope
&amp;nbsp; Set pEnv = New Envelope
&amp;nbsp; pEnv.YMin = EnvYMin
&amp;nbsp; pEnv.XMin = EnvXMin
&amp;nbsp; pEnv.Height = EnvHeight
&amp;nbsp; pEnv.Width = EnvWidth
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 1 To Numbers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Create a new EnvelopeElement and set its Geometry
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pElem = New RectangleElement
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pElem.geometry = pEnv
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Add the new element at Z order zero
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pGraCont.AddElement pElem, 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Generate Offset for next rectangle
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pEnv.Offset (EnvWidth / 2), 0

&amp;nbsp;&amp;nbsp;&amp;nbsp; Next i
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; ' Refresh the activeview
&amp;nbsp; pMXDoc.ActiveView.Refresh&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:37:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/drawing-rectangles-and-markers-with-vba/m-p/714992#M19057</guid>
      <dc:creator>FlorianSchulze</dc:creator>
      <dc:date>2021-12-12T06:37:02Z</dc:date>
    </item>
  </channel>
</rss>

