Author Topic: UCS&WCS  (Read 856 times)

0 Members and 1 Guest are viewing this topic.

frtfff

  • Newt
  • Posts: 188
UCS&WCS
« on: October 07, 2011, 09:39:31 pm »
Now ,I can create a new UCS ang set this ucs to current ucs in cad by code,but
1.  I can't transfer ucs to wcs by code
2.  how can I delete this ucs by code.
Here is create a new ucs and set this ucs to current ucs
//
void createNewUcs(AcGePoint3d ptOri,AcGeVector3d vecXAxis,AcGeVector3d vecYAxis,CString ucsName)
{
   AcDbUCSTable *pUcsTbl;
   acdbHostApplicationServices()->workingDatabase()->
      getUCSTable(pUcsTbl,AcDb::kForWrite);
   //
   AcDbUCSTableRecord *pUcsTblRcd = new AcDbUCSTableRecord();
   //
   Acad::ErrorStatus es = pUcsTblRcd->setName(ucsName);
   if (es != Acad::eOk)
   {
      delete pUcsTblRcd;
      pUcsTbl->close();
      return;
   }
   pUcsTblRcd->setOrigin(ptOri);
   pUcsTblRcd->setXAxis(vecXAxis);
   pUcsTblRcd->setYAxis(vecYAxis);
   //
   es = pUcsTbl->add(pUcsTblRcd);
   if (es != Acad::eOk)
   {
      delete pUcsTblRcd;
      pUcsTbl->close();
      return;
   }
   //
   pUcsTblRcd->close();
   pUcsTbl->close();
}//
void setCurrentUcs(CString ucsName)
{
   AcDbUCSTable *pUcsTbl;
   acdbHostApplicationServices()->workingDatabase()->
      getUCSTable(pUcsTbl,AcDb::kForWrite);
   //
   if (!pUcsTbl->has(ucsName))
   {
      pUcsTbl->close();
      return;
   }
   AcDbUCSTableRecord *pUcsTblRcd;
   pUcsTbl->getAt(ucsName,pUcsTblRcd,AcDb::kForRead);
   //
   AcGeMatrix3d mat;
   AcGeVector3d vecXAxis,vecYAxis,vecZAxis;
   vecXAxis = pUcsTblRcd->xAxis();
   vecYAxis = pUcsTblRcd->yAxis();
   vecZAxis = vecXAxis.crossProduct(vecYAxis);
   mat.setCoordSystem(pUcsTblRcd->origin(),vecXAxis,vecYAxis,vecZAxis);
   //
   pUcsTblRcd->close();
   pUcsTbl->close();
   //
   acedSetCurrentUCS(mat);
}//

MP

  • Seagull
  • Posts: 15807
  • Don't be so open-minded that your brains fall out.
Re: UCS&WCS
« Reply #1 on: October 07, 2011, 09:45:52 pm »
Friendly tip: If you surround your code in code tags [code] ... [/code] it's way easier on the eyes:

Code: [Select]
void createNewUcs(AcGePoint3d ptOri,AcGeVector3d vecXAxis,AcGeVector3d vecYAxis,CString ucsName)
{
AcDbUCSTable *pUcsTbl;
acdbHostApplicationServices()->workingDatabase()->
getUCSTable(pUcsTbl,AcDb::kForWrite);
//
AcDbUCSTableRecord *pUcsTblRcd = new AcDbUCSTableRecord();
//
Acad::ErrorStatus es = pUcsTblRcd->setName(ucsName);
if (es != Acad::eOk)
{
delete pUcsTblRcd;
pUcsTbl->close();
return;
}
pUcsTblRcd->setOrigin(ptOri);
pUcsTblRcd->setXAxis(vecXAxis);
pUcsTblRcd->setYAxis(vecYAxis);
//
es = pUcsTbl->add(pUcsTblRcd);
if (es != Acad::eOk)
{
delete pUcsTblRcd;
pUcsTbl->close();
return;
}
//
pUcsTblRcd->close();
pUcsTbl->close();
}

Code: [Select]
void setCurrentUcs(CString ucsName)
{
AcDbUCSTable *pUcsTbl;
acdbHostApplicationServices()->workingDatabase()->
getUCSTable(pUcsTbl,AcDb::kForWrite);
//
if (!pUcsTbl->has(ucsName))
{
pUcsTbl->close();
return;
}
AcDbUCSTableRecord *pUcsTblRcd;
pUcsTbl->getAt(ucsName,pUcsTblRcd,AcDb::kForRead);
//
AcGeMatrix3d mat;
AcGeVector3d vecXAxis,vecYAxis,vecZAxis;
vecXAxis = pUcsTblRcd->xAxis();
vecYAxis = pUcsTblRcd->yAxis();
vecZAxis = vecXAxis.crossProduct(vecYAxis);
mat.setCoordSystem(pUcsTblRcd->origin(),vecXAxis,vecYAxis,vecZAxis);
//
pUcsTblRcd->close();
pUcsTbl->close();
//
acedSetCurrentUCS(mat);
}
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | Dropbox | O'Reilly School | UltraEdit

frtfff

  • Newt
  • Posts: 188
Re: UCS&WCS
« Reply #2 on: October 09, 2011, 09:23:54 pm »
I have solved how to deleteExistingUcs from ucs list.But can't transfer to wcs. :-(

frtfff

  • Newt
  • Posts: 188
Re: UCS&WCS
« Reply #3 on: October 09, 2011, 09:30:08 pm »
Code: [Select]
void deleteUcs()
{
//

//
}

highflyingbird

  • Bull Frog
  • Posts: 385
  • Later equals never.
Re: UCS&WCS
« Reply #4 on: October 21, 2011, 12:08:20 am »
like this:
Code: [Select]
AcGeMatrix3d mat;
mat.setToIdentity();
acedSetCurrentUCS(mat);
I am a bilingualist,Chinese and Chinglish.

frtfff

  • Newt
  • Posts: 188
Re: UCS&WCS
« Reply #5 on: October 21, 2011, 05:20:12 am »
Thanks/