ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to clone a dimstyle and modify its name?

1 REPLY 1
SOLVED
Reply
Message 1 of 2
dziwve67853
208 Views, 1 Reply

How to clone a dimstyle and modify its name?

Given a dimension style named ISO-25, how to clone this dimension style and modify it to ISO-25-1?

 

AcDbDimStyleTable* pDimStyleTbl=NULL;  
Acad::ErrorStatus es = acdbCurDwg()->getDimStyleTable(pDimStyleTbl,AcDb::kForWrite);
if (!pDimStyleTbl)
{
acutPrintf(_T("\nerror!"));return;
}
AcDbDimStyleTableRecord* pDimStyleTblRcd = NULL;
es = acdbOpenObject(pDimStyleTblRcd,dimStyleId,AcDb::kForRead);
if(Acad::eOk != es)
{
acutPrintf(_T("\nerror!"));pDimStyleTbl->close();return;
}
 
AcDbDimStyleTableRecord* pCloneDimStyleTblRcd = new AcDbDimStyleTableRecord();
pCloneDimStyleTblRcd->copyFrom(pDimStyleTblRcd);
es = pCloneDimStyleTblRcd->setName(_T("ISO-25-1"));
 
AcDbObjectId tmpDimStyleId;
es = pDimStyleTbl->add(tmpDimStyleId,pCloneDimStyleTblRcd); 
if (Acad::eOk != es)
{
delete pCloneDimStyleTblRcd;pDimStyleTbl->close();return; 
}
pDimStyleTblRcd->close();
pDimStyleTbl->close();
 
 
 
I tried using clone and the current copyfrom.And es=pDimStyleTbl ->add (tmpDimStyleId, pCloneDimStyleTblRcd); The return value is Acad:: eOk.
Can you tell me how to copy a dimstyle? Use deepclone or deepCloneObjects? Please provide me with a sample code. Thank you!
 
Labels (2)
1 REPLY 1
Message 2 of 2
ynapeu
in reply to: dziwve67853

after the add

pCloneDimStyleTblRcd->close();

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups