<?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: How to set current UCS in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513616#M17421</link>
    <description>You might try looking up acedSetCurrentUCS in the sdk docs&lt;BR /&gt;
&lt;BR /&gt;
Daniel</description>
    <pubDate>Mon, 29 Jun 2009 05:42:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-06-29T05:42:34Z</dc:date>
    <item>
      <title>How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513614#M17419</link>
      <description>Currently, I have 2 UCS ( "world" and "xxx")&lt;BR /&gt;
I want to set "xxx" as current UCS in my code. after then&lt;BR /&gt;
 use ads_command(RTSTR, _T("_.UCS"), RTSTR, _T("_Move"), RTSTR, _T("\\"), RTNONE)) == RTNORM) to let user select a new point.&lt;BR /&gt;
&lt;BR /&gt;
But alway create a UCS("unnamed").</description>
      <pubDate>Fri, 26 Jun 2009 09:17:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513614#M17419</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-26T09:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513615#M17420</link>
      <description>I don't know if there is any command can set a certain ucs to current.&lt;BR /&gt;
Or is there any API to do so.</description>
      <pubDate>Mon, 29 Jun 2009 02:47:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513615#M17420</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-29T02:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513616#M17421</link>
      <description>You might try looking up acedSetCurrentUCS in the sdk docs&lt;BR /&gt;
&lt;BR /&gt;
Daniel</description>
      <pubDate>Mon, 29 Jun 2009 05:42:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513616#M17421</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-29T05:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513617#M17422</link>
      <description>Here is a little routine you can use that will set the WCS to UCS, allow to pick a new origin, and set the UCS origin to the picked point:&lt;BR /&gt;
&lt;BR /&gt;
AcGeMatrix3d mat;&lt;BR /&gt;
&lt;BR /&gt;
// Set to world UCS&lt;BR /&gt;
mat.setCoordSystem(AcGePoint3d(0,0,0), AcGeVector3d::kXAxis, AcGeVector3d::kYAxis, AcGeVector3d::kZAxis);&lt;BR /&gt;
acedSetCurrentUCS(mat);&lt;BR /&gt;
&lt;BR /&gt;
// Setup the new UCS&lt;BR /&gt;
AcGePoint3d ucsOrig(5, 10, 12);&lt;BR /&gt;
AcGeVector3d zAxis(0.3, 1.92, 0.89);&lt;BR /&gt;
AcGeVector3d xAxis = zAxis.perpVector();&lt;BR /&gt;
AcGeVector3d yAxis = zAxis.crossProduct(xAxis);&lt;BR /&gt;
xAxis.normalize();&lt;BR /&gt;
yAxis.normalize();&lt;BR /&gt;
zAxis.normalize();&lt;BR /&gt;
mat.setCoordSystem(ucsOrig, xAxis, yAxis, zAxis);&lt;BR /&gt;
acedSetCurrentUCS(mat);&lt;BR /&gt;
&lt;BR /&gt;
// Translate the UCS (world) origin for use in acedGetPoint (optional).&lt;BR /&gt;
AcGePoint3d transPnt;&lt;BR /&gt;
acdbWcs2Ucs(asDblArray(ucsOrig), asDblArray(transPnt), false);&lt;BR /&gt;
&lt;BR /&gt;
AcGePoint3d pnt;&lt;BR /&gt;
if(acedGetPoint(asDblArray(transPnt), _T("\nPick UCS origin: "), asDblArray(pnt)) != RTNORM)&lt;BR /&gt;
return;&lt;BR /&gt;
pnt.transformBy(mat);&lt;BR /&gt;
&lt;BR /&gt;
// Set the UCS to the point picked.&lt;BR /&gt;
mat.setCoordSystem(pnt, xAxis, yAxis, zAxis);&lt;BR /&gt;
acedSetCurrentUCS(mat);</description>
      <pubDate>Mon, 29 Jun 2009 12:09:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513617#M17422</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2009-06-29T12:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513618#M17423</link>
      <description>Thanks cadmeup&lt;BR /&gt;
acedSetCurrentUCS takes the parameter AcGeMatrix3d, which only contain the information of position and axis.&lt;BR /&gt;
&lt;BR /&gt;
For example, I have two UCS(WORLD, testUCS),&lt;BR /&gt;
And when I get the the matrix of testUCS and then set it, it will only copy the position and axis information to current UCS. But what I want is set the testUCS to current.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
    AcDbUCSTable *pUcsTbl;&lt;BR /&gt;
    acdbHostApplicationServices()-&amp;gt;workingDatabase()&lt;BR /&gt;
        -&amp;gt;getUCSTable(pUcsTbl, AcDb::kForRead);&lt;BR /&gt;
    if (!pUcsTbl-&amp;gt;has(_T("testUCS"))) &lt;BR /&gt;
    {&lt;BR /&gt;
        pUcsTbl-&amp;gt;close();&lt;BR /&gt;
        return false;&lt;BR /&gt;
    }&lt;BR /&gt;
    // get UCS table record&lt;BR /&gt;
    AcDbUCSTableRecord *pUcsTblRcd;&lt;BR /&gt;
    pUcsTbl-&amp;gt;getAt(_T("testUCS"), pUcsTblRcd, AcDb::kForRead);&lt;BR /&gt;
&lt;BR /&gt;
    //Get UCS Matrix&lt;BR /&gt;
    AcGeMatrix3d mat;&lt;BR /&gt;
    AcGeVector3d vecXAxis, vecYAxis, vecZAxis;&lt;BR /&gt;
    vecXAxis = pUcsTblRcd-&amp;gt;xAxis();&lt;BR /&gt;
    vecYAxis = pUcsTblRcd-&amp;gt;yAxis();&lt;BR /&gt;
    vecZAxis = vecXAxis.crossProduct(vecYAxis);&lt;BR /&gt;
    mat.setCoordSystem(pUcsTblRcd-&amp;gt;origin(), vecXAxis,&lt;BR /&gt;
        vecYAxis, vecZAxis);&lt;BR /&gt;
    pUcsTblRcd-&amp;gt;close();&lt;BR /&gt;
    pUcsTbl-&amp;gt;close();&lt;BR /&gt;
    // set UCS_OLP to current UCS&lt;BR /&gt;
    acedSetCurrentUCS(mat);</description>
      <pubDate>Tue, 30 Jun 2009 01:04:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513618#M17423</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-30T01:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513619#M17424</link>
      <description>you can set the current ucs for the active viewport like this  &lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
 static void ArxSetUcs_doit(void)&lt;BR /&gt;
 {&lt;BR /&gt;
  Acad::ErrorStatus es = Acad::eOk;&lt;BR /&gt;
  {&lt;BR /&gt;
   AcDbDatabase *pDb = &lt;BR /&gt;
    acdbHostApplicationServices()-&amp;gt;workingDatabase();&lt;BR /&gt;
&lt;BR /&gt;
   AcDbUCSTablePointer&lt;BR /&gt;
    pUCSTable(pDb-&amp;gt;UCSTableId(), AcDb::kForRead);&lt;BR /&gt;
&lt;BR /&gt;
   if( (es = pUCSTable.openStatus()) != Acad::eOk ) &lt;BR /&gt;
   {&lt;BR /&gt;
    acutPrintf(ACRX_T("Fail %s @ Line %d"), &lt;BR /&gt;
     acadErrorStatusText(es), __LINE__);&lt;BR /&gt;
    return;&lt;BR /&gt;
   }&lt;BR /&gt;
&lt;BR /&gt;
   AcDbViewportTablePointer pViewportTable&lt;BR /&gt;
    (pDb-&amp;gt;viewportTableId(), AcDb::kForRead);&lt;BR /&gt;
&lt;BR /&gt;
   if((es = pViewportTable.openStatus()) != Acad::eOk)&lt;BR /&gt;
   {&lt;BR /&gt;
    acutPrintf(ACRX_T("Fail %s @ Line %d"), &lt;BR /&gt;
     acadErrorStatusText(es), __LINE__);&lt;BR /&gt;
    return;&lt;BR /&gt;
   }&lt;BR /&gt;
&lt;BR /&gt;
   AcDbObjectId activeViewPortId;&lt;BR /&gt;
&lt;BR /&gt;
   if((es = pViewportTable-&amp;gt;getAt&lt;BR /&gt;
    (_T("*Active"),activeViewPortId)) !=  Acad::eOk) &lt;BR /&gt;
   {&lt;BR /&gt;
    acutPrintf(ACRX_T("Fail %s @ Line %d"), &lt;BR /&gt;
     acadErrorStatusText(es), __LINE__);&lt;BR /&gt;
    return;&lt;BR /&gt;
   }&lt;BR /&gt;
&lt;BR /&gt;
   AcDbViewportTableRecordPointer &lt;BR /&gt;
    pActiveViewportTableRecord&lt;BR /&gt;
    (activeViewPortId, AcDb::kForWrite);&lt;BR /&gt;
&lt;BR /&gt;
   if((es = pActiveViewportTableRecord.openStatus())&lt;BR /&gt;
    != Acad::eOk)&lt;BR /&gt;
   {&lt;BR /&gt;
    acutPrintf(ACRX_T("Fail %s @ Line %d"), &lt;BR /&gt;
     acadErrorStatusText(es), __LINE__);&lt;BR /&gt;
    return;&lt;BR /&gt;
   }&lt;BR /&gt;
&lt;BR /&gt;
   if( pUCSTable-&amp;gt;has(_T("testUCS") ))&lt;BR /&gt;
   {&lt;BR /&gt;
    AcDbObjectId testUCSId;&lt;BR /&gt;
    if( (es = pUCSTable-&amp;gt;getAt&lt;BR /&gt;
     (_T("testUCS"),testUCSId) ) !=  Acad::eOk )&lt;BR /&gt;
    {&lt;BR /&gt;
     acutPrintf(ACRX_T("Fail %s @ Line %d"), &lt;BR /&gt;
      acadErrorStatusText(es), __LINE__);&lt;BR /&gt;
     return;&lt;BR /&gt;
    }&lt;BR /&gt;
&lt;BR /&gt;
    if(!testUCSId.isNull())&lt;BR /&gt;
    {&lt;BR /&gt;
     pActiveViewportTableRecord-&amp;gt;setUcs(testUCSId);&lt;BR /&gt;
    }&lt;BR /&gt;
   }&lt;BR /&gt;
  }&lt;BR /&gt;
&lt;BR /&gt;
  if((es = acedVportTableRecords2Vports()) &lt;BR /&gt;
   !=  Acad::eOk)&lt;BR /&gt;
  {&lt;BR /&gt;
   acutPrintf(ACRX_T("Fail %s @ Line %d"), &lt;BR /&gt;
    acadErrorStatusText(es), __LINE__);&lt;BR /&gt;
   return;&lt;BR /&gt;
  }&lt;BR /&gt;
 }&lt;BR /&gt;
 {code}</description>
      <pubDate>Tue, 30 Jun 2009 03:03:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513619#M17424</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-30T03:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513620#M17425</link>
      <description>It's kind of confusing with the code you posted, because it looks like it should set the WCS to a UCS (to a current UCS) with the values that are stored within the UCS table record, if they are different from WCS or the current UCS. &lt;BR /&gt;
&lt;BR /&gt;
When you create a AcDbUCSTableRecord it is initialized like this:&lt;BR /&gt;
"Initializes the UCS origin to (0,0,0), the UCS X axis to (1,0,0), and the UCS Y axis to (0,1,0) in WCS coordinates."&lt;BR /&gt;
&lt;BR /&gt;
It is basically set as a world UCS (WCS).&lt;BR /&gt;
&lt;BR /&gt;
If you don't change any of the values that are stored with this UCS, whenever you open it and try to set it as "current" it will always seem like it doesn't have any effect, unless your current UCS is something other than WCS. You have to open the 'testUCS' for write and call the class methods 'setXAxis', 'setYAxis', and 'setOrigin' (and possibly 'setUcsBaseOrigin'). The next time you open this UCS record it will have values that might be other than WCS values and it will reflect a different coord sys. 'acedSetCurrentUCS' won't change any values that may be stored with the 'testUCS' record.&lt;BR /&gt;
&lt;BR /&gt;
Also, before you set the record to the UCS table make sure you give it a name using 'AcDbSymbolTableRecord::setName' that is a unique name within the UCS table, or with a name of a record that you want to replace within the table.&lt;BR /&gt;
&lt;BR /&gt;
Hope it makes sense yelixing! UCS's can get confusing sometimes.</description>
      <pubDate>Tue, 30 Jun 2009 03:03:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513620#M17425</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2009-06-30T03:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513621#M17426</link>
      <description>Thanks cadmeup and danielm103&lt;BR /&gt;
&lt;BR /&gt;
I found a way, ads_command(RTSTR, _T("_.UCS"), RTSTR, _T("NAmed"), RTSTR, _T("Restore"),&lt;BR /&gt;
          RTSTR, _T("testUCS"), RTNONE);</description>
      <pubDate>Tue, 30 Jun 2009 08:36:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513621#M17426</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-30T08:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513622#M17427</link>
      <description>Thanks danielm103, your solution worked, even on the modeless dialog case.&lt;BR /&gt;
&lt;BR /&gt;
One additional point:&lt;BR /&gt;
&lt;BR /&gt;
before acedVportTableRecords2Vports(), need close VportTable and its record.</description>
      <pubDate>Thu, 11 Mar 2010 09:33:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513622#M17427</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-03-11T09:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current UCS</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513623#M17428</link>
      <description>Glad it works for you,&lt;BR /&gt;
The smart pointers should close those items, I added a extra set of braces for the scope.. I should have made a comment</description>
      <pubDate>Sat, 13 Mar 2010 09:18:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-set-current-ucs/m-p/2513623#M17428</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-03-13T09:18:29Z</dc:date>
    </item>
  </channel>
</rss>

