<?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 create annotative objects? in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-create-annotative-objects/m-p/2544000#M17094</link>
    <description>Okay, I got this working. It's not the call to AcDbAnnotativeObjectPE::setAnnotative() that adds the data to the object's extension dictionary, it's actually AcDbObjectContextInterface::addContext()... duh.. And after messing with it for a while I found out that AcDbAnnotativeObjectPE::setAnnotative() will return Acad::eInvalidInput if AcDbAnnotativeObjectPE::annotative(object) == true. So I modified my SetAnnotative function to do this:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
//-----------------------------------------------------------------------------&lt;BR /&gt;
Acad::ErrorStatus&lt;BR /&gt;
SetAnnotative(	AcDbObject*	pObject,&lt;BR /&gt;
				bool		annotative)&lt;BR /&gt;
{&lt;BR /&gt;
	ASSERT(pObject != NULL);&lt;BR /&gt;
	AcDbAnnotativeObjectPE* pAnnoPE = ACRX_PE_PTR(pObject, AcDbAnnotativeObjectPE);&lt;BR /&gt;
	if (pAnnoPE == NULL)&lt;BR /&gt;
		return Acad::eNullPtr;&lt;BR /&gt;
	if (pAnnoPE-&amp;gt;annotative(pObject) == annotative)&lt;BR /&gt;
		return Acad::eOk;&lt;BR /&gt;
	return pAnnoPE-&amp;gt;setAnnotative(pObject, annotative);&lt;BR /&gt;
}&lt;BR /&gt;
{code}</description>
    <pubDate>Fri, 21 Aug 2009 16:02:06 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-08-21T16:02:06Z</dc:date>
    <item>
      <title>How to create annotative objects?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-create-annotative-objects/m-p/2543999#M17093</link>
      <description>What do I need to do to create a AcDbBlockReference that supports AcDbAnnotationScale? When I use the Acad Insert command to insert an annotative block it creates an extension dictionary that looks something like this:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
AcDbBlockReference&lt;BR /&gt;
	Extentension Dictionary&lt;BR /&gt;
		"AcDbContextDataManager" Dictionary&lt;BR /&gt;
			"ACDB_ANNOTATIONSCALES" Dictionary&lt;BR /&gt;
				"ACDB_BLKREFOBJECTCONTEXTDATA_CLASS" Object&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
The sparse documentation that exists (and the sample project) make it seem like all you have to do is:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
//-----------------------------------------------------------------------------&lt;BR /&gt;
Acad::ErrorStatus&lt;BR /&gt;
InsertBlock(	AcDbObjectId			blockRecordId,&lt;BR /&gt;
				AcDbObjectId			ownerRecordId,&lt;BR /&gt;
				AcDbBlockReference*&amp;amp;	pReference)&lt;BR /&gt;
{&lt;BR /&gt;
	pReference = new AcDbBlockReference();&lt;BR /&gt;
	pReference-&amp;gt;setBlockTableRecord(blockRecordId);&lt;BR /&gt;
	PsdbDbxObjectPointer&lt;ACDBBLOCKTABLERECORD&gt; pOwnerRecord;&lt;BR /&gt;
	pOwnerRecord.open(ownerRecordId, AcDb::kForWrite);&lt;BR /&gt;
	pOwnerRecord-&amp;gt;appendAcDbEntity(pReference);&lt;BR /&gt;
	PsdbDbxObjectPointer&lt;ACDBBLOCKTABLERECORD&gt; pBlockRecord;&lt;BR /&gt;
	pBlockRecord.open(blockRecordId, AcDb::kForRead);&lt;BR /&gt;
	AcDbDatabase* pDatabase = pBlockRecord-&amp;gt;database();&lt;BR /&gt;
	AcDbBlockTableRecordIterator* pIterator;&lt;BR /&gt;
	pBlockRecord-&amp;gt;newIterator(pIterator);&lt;BR /&gt;
	for (pIterator-&amp;gt;start(); !pIterator-&amp;gt;done(); pIterator-&amp;gt;step()) {&lt;BR /&gt;
		PsdbDbxObjectPointer&lt;ACDBENTITY&gt; pEntity;&lt;BR /&gt;
		pIterator-&amp;gt;getEntity(pEntity, AcDb::kForRead);&lt;BR /&gt;
		AcDbAttributeDefinition* pAttDef &lt;BR /&gt;
			= AcDbAttributeDefinition::cast(pEntity.object());&lt;BR /&gt;
		if (pAttDef != NULL &amp;amp;&amp;amp; !pAttDef-&amp;gt;isConstant()) {&lt;BR /&gt;
			PsdbDbxObjectPointer&lt;ACDBATTRIBUTE&gt; pAttribute;&lt;BR /&gt;
			pAttribute.create();&lt;BR /&gt;
			pAttribute-&amp;gt;setAttributeFromBlock(pAttDef, pReference-&amp;gt;blockTransform());&lt;BR /&gt;
			AcDbObjectId attribuiteId;&lt;BR /&gt;
			pReference-&amp;gt;appendAttribute(attribuiteId, pAttribute);&lt;BR /&gt;
		}&lt;BR /&gt;
	}&lt;BR /&gt;
	delete pIterator;&lt;BR /&gt;
	if (ObjectIsAnnotative(pBlockRecord)) {&lt;BR /&gt;
		SetAnnotative(pReference);&lt;BR /&gt;
		AcDbAnnotationScale* pAnnoScale = pDatabase-&amp;gt;cannoscale();&lt;BR /&gt;
		AddContextToObject(pReference, *pAnnoScale);&lt;BR /&gt;
		delete pAnnoScale;&lt;BR /&gt;
	}	&lt;BR /&gt;
	return Acad::eOk;&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
//-----------------------------------------------------------------------------&lt;BR /&gt;
Acad::ErrorStatus&lt;BR /&gt;
SetAnnotative(	AcDbObject*	pObject,&lt;BR /&gt;
				bool		annotative)&lt;BR /&gt;
{&lt;BR /&gt;
	AcDbAnnotativeObjectPE* pAnnoPE &lt;BR /&gt;
		= ACRX_PE_PTR(pObject, AcDbAnnotativeObjectPE);&lt;BR /&gt;
	if (pAnnoPE == NULL)&lt;BR /&gt;
		return Acad::eNullPtr;&lt;BR /&gt;
	return pAnnoPE-&amp;gt;setAnnotative(pObject, annotative);&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
//-----------------------------------------------------------------------------&lt;BR /&gt;
Acad::ErrorStatus&lt;BR /&gt;
AddContextToObject(	AcDbObject*					pObject,&lt;BR /&gt;
					const AcDbObjectContext&amp;amp;	context)&lt;BR /&gt;
{&lt;BR /&gt;
	AcDbObjectContextInterface* pContextInterface &lt;BR /&gt;
		= ACRX_PE_PTR(pObject, AcDbObjectContextInterface);&lt;BR /&gt;
	if (pContextInterface == NULL) &lt;BR /&gt;
		return Acad::eNullPtr;&lt;BR /&gt;
	return pContextInterface-&amp;gt;addContext(pObject, context);&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
//-----------------------------------------------------------------------------&lt;BR /&gt;
bool&lt;BR /&gt;
ObjectIsAnnotative(AcDbObject* pObject)&lt;BR /&gt;
{&lt;BR /&gt;
	AcDbAnnotativeObjectPE* pAnnoPE &lt;BR /&gt;
		= ACRX_PE_PTR(pObject, AcDbAnnotativeObjectPE);&lt;BR /&gt;
	if (pAnnoPE == NULL)&lt;BR /&gt;
		return false;&lt;BR /&gt;
	return pAnnoPE-&amp;gt;annotative(pObject);&lt;BR /&gt;
}&lt;BR /&gt;
{code}&lt;BR /&gt;
&lt;BR /&gt;
I was hoping that AcDbAnnotativeObjectPE::setAnnotative() would create the required objects inside the reference's extension dictionary; but for some reason, AcDbAnnotativeObjectPE::setAnnotative() returns Acad::eInvalidInput. Am I just doing this all wrong?&lt;/ACDBATTRIBUTE&gt;&lt;/ACDBENTITY&gt;&lt;/ACDBBLOCKTABLERECORD&gt;&lt;/ACDBBLOCKTABLERECORD&gt;</description>
      <pubDate>Fri, 21 Aug 2009 00:49:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-create-annotative-objects/m-p/2543999#M17093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-21T00:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create annotative objects?</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/how-to-create-annotative-objects/m-p/2544000#M17094</link>
      <description>Okay, I got this working. It's not the call to AcDbAnnotativeObjectPE::setAnnotative() that adds the data to the object's extension dictionary, it's actually AcDbObjectContextInterface::addContext()... duh.. And after messing with it for a while I found out that AcDbAnnotativeObjectPE::setAnnotative() will return Acad::eInvalidInput if AcDbAnnotativeObjectPE::annotative(object) == true. So I modified my SetAnnotative function to do this:&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
//-----------------------------------------------------------------------------&lt;BR /&gt;
Acad::ErrorStatus&lt;BR /&gt;
SetAnnotative(	AcDbObject*	pObject,&lt;BR /&gt;
				bool		annotative)&lt;BR /&gt;
{&lt;BR /&gt;
	ASSERT(pObject != NULL);&lt;BR /&gt;
	AcDbAnnotativeObjectPE* pAnnoPE = ACRX_PE_PTR(pObject, AcDbAnnotativeObjectPE);&lt;BR /&gt;
	if (pAnnoPE == NULL)&lt;BR /&gt;
		return Acad::eNullPtr;&lt;BR /&gt;
	if (pAnnoPE-&amp;gt;annotative(pObject) == annotative)&lt;BR /&gt;
		return Acad::eOk;&lt;BR /&gt;
	return pAnnoPE-&amp;gt;setAnnotative(pObject, annotative);&lt;BR /&gt;
}&lt;BR /&gt;
{code}</description>
      <pubDate>Fri, 21 Aug 2009 16:02:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/how-to-create-annotative-objects/m-p/2544000#M17094</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-08-21T16:02:06Z</dc:date>
    </item>
  </channel>
</rss>

