<?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: Changing TARGET Variable by code in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441599#M16222</link>
    <description>jeromeb wrote:&lt;BR /&gt;
&amp;gt; Finally I managed to get som e results regarding my TARGET problem. It &lt;BR /&gt;
&amp;gt; seems that by changing values using DVIEW you change the target &lt;BR /&gt;
&amp;gt; coordinates. So I managed to set thet TARGET to 0,0,0 by hand, now I'll &lt;BR /&gt;
&amp;gt; figure out how to put this into usefull code.&lt;BR /&gt;
&lt;BR /&gt;
Hello jerome&lt;BR /&gt;
&lt;BR /&gt;
We have encountered something like your problem I think.&lt;BR /&gt;
&lt;BR /&gt;
I have made the following VBA Sub to Reset the Center+Target coordinates &lt;BR /&gt;
for the current viewport in Modelspace of the active drawing in AutoCAD:&lt;BR /&gt;
&lt;BR /&gt;
This method may help you also our give you some ideas.&lt;BR /&gt;
&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
Public Sub ResetMSViewPort()&lt;BR /&gt;
'Reset Current View/Camera for Current Model Space ViewPort&lt;BR /&gt;
     Dim oACADDraw As AcadDocument&lt;BR /&gt;
     Dim oCurViewP As AcadViewport&lt;BR /&gt;
     Dim dCenter(1) As Double&lt;BR /&gt;
     Dim dTarget(2) As Double&lt;BR /&gt;
     'Get Current AutoCAD Drawing Document Object&lt;BR /&gt;
     Set oACADDraw = ThisDrawing&lt;BR /&gt;
     If Not (oACADDraw Is Nothing) Then&lt;BR /&gt;
         'Check for Model Space Active&lt;BR /&gt;
         If (oACADDraw.ActiveSpace = acModelSpace) Then&lt;BR /&gt;
             'Get the Active ViewPort Object&lt;BR /&gt;
             Set oCurViewP = oACADDraw.ActiveViewport&lt;BR /&gt;
             If Not (oCurViewP Is Nothing) Then&lt;BR /&gt;
                 'Set ViewPort Center Coordinates to (X,Y)=(0,0)&lt;BR /&gt;
                 dCenter(0) = 0#&lt;BR /&gt;
                 dCenter(1) = 0#&lt;BR /&gt;
                 'Set the ViewPort Center Coordinates&lt;BR /&gt;
                 oCurViewP.Center = dCenter&lt;BR /&gt;
                 'Set ViewPort Target Coordinates to (X,Y,Z)=(0,0,0)&lt;BR /&gt;
                 dTarget(0) = 0#&lt;BR /&gt;
                 dTarget(1) = 0#&lt;BR /&gt;
                 dTarget(2) = 0#&lt;BR /&gt;
                 'Set the ViewPort Target Coordinates&lt;BR /&gt;
                 oCurViewP.Target = dTarget&lt;BR /&gt;
                 'Set the Active ViewPort to the Modified ViewPort Object&lt;BR /&gt;
                 oACADDraw.ActiveViewport = oCurViewP&lt;BR /&gt;
                 'Release ViewPort Object&lt;BR /&gt;
                 Set oCurViewP = Nothing&lt;BR /&gt;
             End If&lt;BR /&gt;
         End If&lt;BR /&gt;
         'Release Document Object&lt;BR /&gt;
         Set oACADDraw = Nothing&lt;BR /&gt;
     End If&lt;BR /&gt;
     Exit Sub&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
Jens Bejer Pedersen</description>
    <pubDate>Thu, 05 Mar 2009 12:00:06 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-03-05T12:00:06Z</dc:date>
    <item>
      <title>Changing TARGET Variable by code</title>
      <link>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441595#M16218</link>
      <description>We are using a plotroutine in VBA wich works fine. However, sometimes the plotwindows gets moved around and it has taken me quite some time to figure out what is causing the problem. I found out it has something to do with the TARGET Variable. When making a good plot the TARGET coordinates are 0,0,0 but when the plot gets moved is had coordinates like 179935,69574,0. The problem is that this variable is a READ only.&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know how I could change the TARGET variable in VBA code so I can fix this in the routine? There has to be some way because the drawing started out with 0,0,0 coordinates, so something changed these values. Any help would be greatly appreciated.</description>
      <pubDate>Wed, 04 Mar 2009 11:38:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441595#M16218</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-04T11:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Changing TARGET Variable by code</title>
      <link>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441596#M16219</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;ThisDrawing.SetVariable sysVarName, sysVarData&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;lt;jeromeb&amp;gt; wrote in message &lt;A&gt;&lt;BR /&gt;
  href="news:6135594@discussion.autodesk.com"&amp;gt;news:6135594@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;We &lt;BR /&gt;
  are using a plotroutine in VBA wich works fine. However, sometimes the &lt;BR /&gt;
  plotwindows gets moved around and it has taken me quite some time to figure &lt;BR /&gt;
  out what is causing the problem. I found out it has something to do with the &lt;BR /&gt;
  TARGET Variable. When making a good plot the TARGET coordinates are 0,0,0 but &lt;BR /&gt;
  when the plot gets moved is had coordinates like 179935,69574,0. The problem &lt;BR /&gt;
  is that this variable is a READ only. Does anyone know how I could change the &lt;BR /&gt;
  TARGET variable in VBA code so I can fix this in the routine? There has to be &lt;BR /&gt;
  some way because the drawing started out with 0,0,0 coordinates, so something &lt;BR /&gt;
  changed these values. Any help would be greatly &lt;BR /&gt;
appreciated.&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 05 Mar 2009 00:15:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441596#M16219</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T00:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Changing TARGET Variable by code</title>
      <link>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441597#M16220</link>
      <description>I've tried the following code but it fails. It generates an error, my first thought is that this is because the target var is a read only variable.&lt;BR /&gt;
Does anyone know how the target variable is set by Autocad in the first place?&lt;BR /&gt;
&lt;BR /&gt;
        Dim arrayData3D(0 To 2) As Double&lt;BR /&gt;
        sysVarName = "TARGET"&lt;BR /&gt;
        arrayData3D(0) = 1#: arrayData3D(1) = 1#: arrayData3D(2) = 0&lt;BR /&gt;
        sysVarData = arrayData3D&lt;BR /&gt;
        &lt;BR /&gt;
        ThisDrawing.SetVariable sysVarName, sysVarData</description>
      <pubDate>Thu, 05 Mar 2009 09:05:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441597#M16220</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T09:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Changing TARGET Variable by code</title>
      <link>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441598#M16221</link>
      <description>Finally I managed to get som e results regarding my TARGET problem. It seems that by changing values using DVIEW you change the target coordinates. So I managed to set thet TARGET to 0,0,0 by hand, now I'll figure out how to put this into usefull code.</description>
      <pubDate>Thu, 05 Mar 2009 11:16:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441598#M16221</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T11:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Changing TARGET Variable by code</title>
      <link>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441599#M16222</link>
      <description>jeromeb wrote:&lt;BR /&gt;
&amp;gt; Finally I managed to get som e results regarding my TARGET problem. It &lt;BR /&gt;
&amp;gt; seems that by changing values using DVIEW you change the target &lt;BR /&gt;
&amp;gt; coordinates. So I managed to set thet TARGET to 0,0,0 by hand, now I'll &lt;BR /&gt;
&amp;gt; figure out how to put this into usefull code.&lt;BR /&gt;
&lt;BR /&gt;
Hello jerome&lt;BR /&gt;
&lt;BR /&gt;
We have encountered something like your problem I think.&lt;BR /&gt;
&lt;BR /&gt;
I have made the following VBA Sub to Reset the Center+Target coordinates &lt;BR /&gt;
for the current viewport in Modelspace of the active drawing in AutoCAD:&lt;BR /&gt;
&lt;BR /&gt;
This method may help you also our give you some ideas.&lt;BR /&gt;
&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
Public Sub ResetMSViewPort()&lt;BR /&gt;
'Reset Current View/Camera for Current Model Space ViewPort&lt;BR /&gt;
     Dim oACADDraw As AcadDocument&lt;BR /&gt;
     Dim oCurViewP As AcadViewport&lt;BR /&gt;
     Dim dCenter(1) As Double&lt;BR /&gt;
     Dim dTarget(2) As Double&lt;BR /&gt;
     'Get Current AutoCAD Drawing Document Object&lt;BR /&gt;
     Set oACADDraw = ThisDrawing&lt;BR /&gt;
     If Not (oACADDraw Is Nothing) Then&lt;BR /&gt;
         'Check for Model Space Active&lt;BR /&gt;
         If (oACADDraw.ActiveSpace = acModelSpace) Then&lt;BR /&gt;
             'Get the Active ViewPort Object&lt;BR /&gt;
             Set oCurViewP = oACADDraw.ActiveViewport&lt;BR /&gt;
             If Not (oCurViewP Is Nothing) Then&lt;BR /&gt;
                 'Set ViewPort Center Coordinates to (X,Y)=(0,0)&lt;BR /&gt;
                 dCenter(0) = 0#&lt;BR /&gt;
                 dCenter(1) = 0#&lt;BR /&gt;
                 'Set the ViewPort Center Coordinates&lt;BR /&gt;
                 oCurViewP.Center = dCenter&lt;BR /&gt;
                 'Set ViewPort Target Coordinates to (X,Y,Z)=(0,0,0)&lt;BR /&gt;
                 dTarget(0) = 0#&lt;BR /&gt;
                 dTarget(1) = 0#&lt;BR /&gt;
                 dTarget(2) = 0#&lt;BR /&gt;
                 'Set the ViewPort Target Coordinates&lt;BR /&gt;
                 oCurViewP.Target = dTarget&lt;BR /&gt;
                 'Set the Active ViewPort to the Modified ViewPort Object&lt;BR /&gt;
                 oACADDraw.ActiveViewport = oCurViewP&lt;BR /&gt;
                 'Release ViewPort Object&lt;BR /&gt;
                 Set oCurViewP = Nothing&lt;BR /&gt;
             End If&lt;BR /&gt;
         End If&lt;BR /&gt;
         'Release Document Object&lt;BR /&gt;
         Set oACADDraw = Nothing&lt;BR /&gt;
     End If&lt;BR /&gt;
     Exit Sub&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
Jens Bejer Pedersen</description>
      <pubDate>Thu, 05 Mar 2009 12:00:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/changing-target-variable-by-code/m-p/2441599#M16222</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-03-05T12:00:06Z</dc:date>
    </item>
  </channel>
</rss>

