<?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: Problem with custom blockReference in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/problem-with-custom-blockreference/m-p/9538473#M4464</link>
    <description>Classes derived from AcDbBlockReference cannot have AcDbAttributes.</description>
    <pubDate>Mon, 25 May 2020 15:49:36 GMT</pubDate>
    <dc:creator>artc2</dc:creator>
    <dc:date>2020-05-25T15:49:36Z</dc:date>
    <item>
      <title>Problem with custom blockReference</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/problem-with-custom-blockreference/m-p/9537927#M4463</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a class inherited from AcDbBlockReference:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;class PICBlock : public AcDbBlockReference
{
public:
	ACRX_DECLARE_MEMBERS(PICBlock);
	static void makeMembers(AcRxMemberCollectionBuilder&amp;amp; collectionBuilder, void* customData);

protected:
	static Adesk::UInt32 kCurrentVersionNumber;

public:
	PICBlock();
	PICBlock(const AcGePoint3d&amp;amp; position, AcDbObjectId  blockTableRec);

	Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const final;
	Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler)final;

	Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler) const final;
	Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler)final;

	Acad::ErrorStatus subClose()override;
	void setManagedWrapper(gcroot&amp;lt;Autodesk::PIC::MgPICBlock^&amp;gt; p);

private:

	gcroot&amp;lt;Autodesk::PIC::MgPICBlock^&amp;gt; m_pManaged; // the managed wrapper pointer.  
};


Adesk::UInt32 PICBlock::kCurrentVersionNumber = 1;

ACRX_DXF_DEFINE_MEMBERS_WITH_PROPERTIES(
	PICBlock, AcDbBlockReference,
	AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
	AcDbProxyEntity::kNoOperation, PIC-BLOCK,
	PICBLOCK
	"|Product Desc:     PIC-ACAD"
	"|Company:          So.Build"
	"|WEB Address:      www.sobuild.fr",
	PICBlock::makeMembers
	)


void PICBlock::makeMembers(
	AcRxMemberCollectionBuilder&amp;amp; collectionBuilder,
	void* customData)
{
	readFromResource("PIC_Attributs.xml", collectionBuilder);
}


PICBlock::PICBlock() : AcDbBlockReference()
{
	//
}

PICBlock::PICBlock(const AcGePoint3d&amp;amp; position, AcDbObjectId  blockTableRec) : AcDbBlockReference(position, blockTableRec)
{
	//
}

Acad::ErrorStatus PICBlock::dwgOutFields(AcDbDwgFiler* pFiler) const
{
	Acad::ErrorStatus retStat = AcDbBlockReference::dwgOutFields(pFiler);
	if (retStat != Acad::eOk)
		return retStat;

	retStat = pFiler-&amp;gt;writeUInt32(PICBlock::kCurrentVersionNumber);
	return retStat;
}

Acad::ErrorStatus PICBlock::dwgInFields(AcDbDwgFiler* pFiler)
{
	assertWriteEnabled();
	Acad::ErrorStatus retStat = AcDbBlockReference::dwgInFields(pFiler);
	if (retStat != Acad::eOk)
		return retStat;

	Adesk::UInt32 uiVersion = 0;
	retStat = pFiler-&amp;gt;readUInt32(&amp;amp;uiVersion);
	return retStat;
}

Acad::ErrorStatus PICBlock::dxfOutFields(AcDbDxfFiler* pFiler) const
{
	Acad::ErrorStatus retStat = AcDbBlockReference::dxfOutFields(pFiler);
	if (retStat != Acad::eOk)
		return retStat;

	retStat = pFiler-&amp;gt;writeUInt32(AcDb::kDxfInt32, PICBlock::kCurrentVersionNumber);
	return retStat;
}

Acad::ErrorStatus PICBlock::dxfInFields(AcDbDxfFiler* pFiler)
{
	assertWriteEnabled();
	Acad::ErrorStatus retStat = AcDbBlockReference::dxfInFields(pFiler);
	if (retStat != Acad::eOk)
		return retStat;

	resbuf data;
	Adesk::UInt32 uiVersion = 0;
	retStat = pFiler-&amp;gt;readItem(&amp;amp;data);
	if ((data.restype != AcDb::kDxfInt32) || (retStat != Acad::eOk))
		return (retStat != Acad::eOk) ? retStat : Acad::eNotApplicable;
	uiVersion = data.resval.rint;

	return retStat;
}

Acad::ErrorStatus PICBlock::subClose()
{
	Acad::ErrorStatus es;
	if ((es = AcDbBlockReference::subClose()) != Acad::eOk)
		return es;

	if (isWriteEnabled() == Adesk::kTrue)
	{
		//You have to cast it back to the managed type to do a null check:
		if (static_cast&amp;lt;Autodesk::PIC::MgPICBlock^&amp;gt;(m_pManaged) != nullptr)
		{
			// Call the method on the wrapper which will propagate to all managed
			// listeners of this event...
			m_pManaged-&amp;gt;PICBlockModified(ToObjectId(objectId()));
		}
	}

	return Acad::eOk;
}

void PICBlock::setManagedWrapper(gcroot&amp;lt;Autodesk::PIC::MgPICBlock^&amp;gt; p)
{
	m_pManaged = p;
}


ACDB_REGISTER_OBJECT_ENTRY_AUTO(PICBlock)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I can't have attributes I have an exception "illegal entity type"&lt;/P&gt;&lt;P&gt;and I can't create a dynamic block.&lt;/P&gt;&lt;P&gt;What I'm doing wrong ?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 25 May 2020 10:36:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/problem-with-custom-blockreference/m-p/9537927#M4463</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-25T10:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with custom blockReference</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/problem-with-custom-blockreference/m-p/9538473#M4464</link>
      <description>Classes derived from AcDbBlockReference cannot have AcDbAttributes.</description>
      <pubDate>Mon, 25 May 2020 15:49:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/problem-with-custom-blockreference/m-p/9538473#M4464</guid>
      <dc:creator>artc2</dc:creator>
      <dc:date>2020-05-25T15:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with custom blockReference</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/problem-with-custom-blockreference/m-p/9557595#M4465</link>
      <description>&lt;P&gt;Hello @Anonymous&amp;nbsp; !&lt;BR /&gt;&lt;BR /&gt;Great to see you here on ObjectARX Forum.&lt;BR /&gt;&lt;BR /&gt;Did &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/656250"&gt;@artc2&lt;/a&gt;&amp;nbsp; 's suggestion helped you? &lt;BR /&gt;If yes, please click on the &lt;FONT color="#008000"&gt;"Accept as Solution"&lt;/FONT&gt; button as then also other community users can easily find and benefit from the information.&lt;BR /&gt;If not please don't hesitate to give an update here in your topic so all members know what ́s the progression on your question is and what might be helpful to achieve what you ́re looking for. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:11:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/problem-with-custom-blockreference/m-p/9557595#M4465</guid>
      <dc:creator>lena.talkhina</dc:creator>
      <dc:date>2020-06-03T13:11:11Z</dc:date>
    </item>
  </channel>
</rss>

