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

Using HardPointer to prevent Text Styles against purging

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
265 Views, 2 Replies

Using HardPointer to prevent Text Styles against purging

Hi All!



I have made an AEC OMF application. It creates new DispReps (a singleton
object), which contains Texts. The application creates two new Text Styles
to be used by their Texts. Everything is OK, but the Text Styles - though
are used by existing object instances - can be purged by the Purge command
of AutoCAD. I would like to protect these Text Styles against purging
mechanism.



I know, that the perfect solution for this problem is to apply Hard Pointer,
but unfortunately I can't use it effectively. I followed the next steps:



1.. To my DispRep class I added a new private AcDbHardPointerId object.
2.. I have overridden the getReferencedObjects function, where I created
the textStyle, I set the value of it to my AcDbHardPointerId variable, and
then added it to the ObjectReferenceMap width the addStyleLocationReference
function.
3.. Please note, that because of some compatibility issues, I must not use
any of the functions: dxfOut, dxfIn, dwgOut, dwgIn. Is it possible. that it
can cause the problem above?


Using the solution above my application works, but can not prevent my
TextStyles against purging.



If anybody has experiences width Hard Pointers, please answer to my problem!



Thanks for any help,

Peter
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

I perserve from purgin with an HardPointerId
stored in an named dictionary.

here is the code fragment for an Hardpointer:

store in:

ads_name ename;
acdbGetAdsName(ename, idLayer);
prbXtn = acutBuildList(AcDb::kDxfHardPointerId, ename,
RTNONE);

read out:

ads_name ename;
memcpy(ename, pTemp->resval.rlname, sizeof(ads_name));
acdbGetObjectId(idLayer, ename);

Bernd

"Péter Zsarnóczky" schrieb im Newsbeitrag
news:ABDAC05EC012A96AF0083EAB1E398FA4@in.WebX.maYIadrTaRb...
> Hi All!
>
>
>
> I have made an AEC OMF application. It creates new DispReps (a singleton
> object), which contains Texts. The application creates two new Text Styles
> to be used by their Texts. Everything is OK, but the Text Styles - though
> are used by existing object instances - can be purged by the Purge command
> of AutoCAD. I would like to protect these Text Styles against purging
> mechanism.
>
>
>
> I know, that the perfect solution for this problem is to apply Hard
Pointer,
> but unfortunately I can't use it effectively. I followed the next steps:
>
>
>
> 1.. To my DispRep class I added a new private AcDbHardPointerId object.
> 2.. I have overridden the getReferencedObjects function, where I created
> the textStyle, I set the value of it to my AcDbHardPointerId variable, and
> then added it to the ObjectReferenceMap width the
addStyleLocationReference
> function.
> 3.. Please note, that because of some compatibility issues, I must not
use
> any of the functions: dxfOut, dxfIn, dwgOut, dwgIn. Is it possible. that
it
> can cause the problem above?
>
>
> Using the solution above my application works, but can not prevent my
> TextStyles against purging.
>
>
>
> If anybody has experiences width Hard Pointers, please answer to my
problem!
>
>
>
> Thanks for any help,
>
> Peter
>
>
>
Message 3 of 3
Anonymous
in reply to: Anonymous

Here is the code of one of my applications:


bool setXdata()
{
AcDbDictionary *pNamedobj;
AcDbDictionary *pDict;
AcDbXrecord *pXrec;
AcDbObjectId dictObjId, xrecObjId;
struct resbuf *prbXtn;


acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(
pNamedobj, AcDb::kForWrite);

// if not exist make new

if (pNamedobj->getAt("CCNC_Brandschutz", (AcDbObject*&) pDict,
AcDb::kForWrite) == Acad::eKeyNotFound)
{
pDict = new AcDbDictionary;
pNamedobj->setAt("CCNC_Brandschutz", pDict, dictObjId);
}

// if no xrecord make new

pNamedobj->close();

if (pDict->getAt("CCNC_Fluchtweg", (AcDbObject*&)pXrec, AcDb::kForWrite) ==
Acad::eKeyNotFound)
{
pXrec = new AcDbXrecord;
pDict->setAt("CCNC_Fluchtweg", pXrec, xrecObjId);
}

pDict->close();

char version[12] = "Version_1.0";

AcDbDatabase *pCurDb = NULL;
AcDbLayerTable *pLayerTable;
AcDbObjectId layId;

pCurDb = acdbHostApplicationServices()->workingDatabase();
pCurDb->getLayerTable(pLayerTable, AcDb::kForRead);
pLayerTable->getAt(dlgFlucht.chrLayer, dlgFlucht.idLayer, false);
pLayerTable->close();

ads_name ename;

acdbGetAdsName(ename, dlgFlucht.idLayer);


prbXtn = acutBuildList( AcDb::kDxfText, version,
AcDb::kDxfInt32, dlgFlucht.fl_color,
AcDb::kDxfHardPointerId, ename,
RTNONE);

if(pXrec->setFromRbChain(*prbXtn) != Acad::eOk)
{
acutPrintf("\nFailed");
}

pXrec->close();

acutRelRb(prbXtn);

return true;
}

here is the read out:

bool getXdata()
{
AcDbDictionary *pNamedDict;
AcDbDictionary *pDict;
AcDbXrecord *pXrec;
AcDbObjectId idLayer;
struct resbuf *prbXtn, *pTemp;


acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(
pNamedDict, AcDb::kForRead);

if (pNamedDict->getAt("CCNC_Brandschutz", (AcDbObject*&) pDict,
AcDb::kForWrite) == Acad::eKeyNotFound)
{
pNamedDict->close();
return false;
}

pNamedDict->close();

if (pDict->getAt("CCNC_Fluchtweg", (AcDbObject*&)pXrec, AcDb::kForRead) ==
Acad::eKeyNotFound)
{
pDict->close();
return false;
}

pDict->close();
pXrec->rbChain(&prbXtn);
pXrec->close();
pTemp = prbXtn;

pTemp = pTemp->rbnext;
if(pTemp->restype == AcDb::kDxfInt32)
dlgFlucht.fl_color = pTemp->resval.rint;
else
return false;

pTemp = pTemp->rbnext;

ads_name ename;

if(pTemp->restype == AcDb::kDxfHardPointerId)
memcpy(ename, pTemp->resval.rlname, sizeof(ads_name));
else
return false;

AcDbObjectId layId;

acdbGetObjectId(layId, ename);
dlgFlucht.idLayer = layId;

ads_relrb(prbXtn);

return true;
}

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

Post to forums  

Autodesk Design & Make Report

”Boost