<?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: Finding block references in external references in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976779#M8467</link>
    <description>&lt;P&gt;I have played around with some arx code and can now detect that there are "anonymous blocks" in the table usually labeled something like *U12 where the number will vary from block to block. Do you know where these anonymous blocks come from? in the article you linked they say "An anonymous block is created for each different state of the dynamic block" but I dont have any states in my blocks.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2017 20:10:48 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-03-27T20:10:48Z</dc:date>
    <item>
      <title>Finding block references in external references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976290#M8462</link>
      <description>&lt;P&gt;I wrote a function that takes a block name, external reference name and a vector of points. The function will look for the external reference and return all the positions of the specified blocks in that xRef. The code works in most cases but sometimes it returns an empty array when I call &amp;nbsp;xRefBlockTableRecord-&amp;gt;getBlockReferenceIds( blockIds ) even though it has already found a block table record in the xRef. Is there someway that blocks are not accessible in the xRef? Or is there an error in my code? Thanks for any advice you can offer. The code is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;bool getPoints( const ACHAR *xRefName, const ACHAR *moduleName, std::vector&amp;lt;AcGePoint2d&amp;gt; *points )
{
	Acad::ErrorStatus errorStatus;
	AcDbDatabase *database = acdbHostApplicationServices()-&amp;gt;workingDatabase();
	AcDbBlockTable *blockTable = NULL;
	AcDbBlockTableRecord *blockTableRecord = NULL;
	AcDbDatabase *xRefDatabase = NULL;
	const ACHAR *xRefPath = NULL;
	AcDbDatabase *xRefDWGDatabase = NULL;
	AcDbBlockTable *xRefBlockTable = NULL;
	AcDbBlockTableRecord *xRefBlockTableRecord = NULL;
	AcDbEntity *ent = NULL;
	AcDbBlockReference *ref = NULL;
	AcDbObjectIdArray blockIds;
	AcDbObjectIdArray refIds;
	//xRef transformations
	double xOffset = 0;
	double yOffset = 0;
	double rotation = 0;

	//Get the block table for our database
	errorStatus = database-&amp;gt;getBlockTable(blockTable, AcDb::kForRead);
	if( errorStatus != Acad::eOk )
	{
		acutPrintf(L"\nError getting block table %s", acadErrorStatusText( errorStatus ) );     
		return false;
	}

	//Get the block table record for the external reference
	errorStatus = blockTable-&amp;gt;getAt( xRefName, blockTableRecord, AcDb::kForRead );
	if( errorStatus != Acad::eOk )
	{
		acutPrintf(L"\nError could not get xref %s %s", xRefName, acadErrorStatusText( errorStatus ) ); 
		blockTable-&amp;gt;close();
		return false;
	}

	//Get the transformation of the xRef
	errorStatus = blockTableRecord-&amp;gt;getBlockReferenceIds( refIds );
	if( errorStatus != Acad::eOk || refIds.length() &amp;lt; 1 )
	{
		acutPrintf(L"\nError could not get xref reference ids %s", acadErrorStatusText( errorStatus ));     
		blockTable-&amp;gt;close();
		return false;
	}

	//Open the reference
	acdbOpenObject( ent, refIds.at(0), AcDb::kForRead );
	if( ent == NULL )
	{
		acutPrintf(L"\nError could not get xref reference entity %s", acadErrorStatusText( errorStatus ));     
		blockTable-&amp;gt;close();
		return false;
	}
	//Cast the reference
	ref = AcDbBlockReference::cast( ent );
	if( ref == NULL )
	{
		acutPrintf(L"\nError could not get xref reference %s", acadErrorStatusText( errorStatus ));     
		blockTable-&amp;gt;close();
		ent-&amp;gt;close();
		return false;
	}
	
	//Get transformations
	xOffset = ref-&amp;gt;position().x;
	yOffset = ref-&amp;gt;position().y;
	rotation = ref-&amp;gt;rotation();

	ent-&amp;gt;close();

	xRefDatabase = blockTableRecord-&amp;gt;xrefDatabase(true);
	blockTable-&amp;gt;close();
	blockTableRecord-&amp;gt;close();

	if( xRefDatabase == NULL )
	{
		acutPrintf(L"\nCould not get external reference database" );
		return false;
	}
	//Get path for external reference dwg file
	xRefPath = acdbOriginalXrefFullPathFor( xRefDatabase ); 
	if( xRefPath == NULL )
	{
		acutPrintf(L"\nCould not get external reference path" );
		return false;
	}
	
	//Get database for the external reference drawing
	xRefDWGDatabase = new AcDbDatabase(Adesk::kFalse);
	errorStatus = xRefDWGDatabase-&amp;gt;readDwgFile(xRefPath);
	if( errorStatus != Acad::eOk )
	{
		acutPrintf(L"\nError could not read xref file %s", acadErrorStatusText( errorStatus ));   
		delete xRefDWGDatabase;
		return false;
	}
	//Get the block table for the open model reference file
	errorStatus = xRefDWGDatabase-&amp;gt;getBlockTable( xRefBlockTable, AcDb::kForRead );
	if( errorStatus != Acad::eOk )
	{
		acutPrintf(L"\nError could not load xref block table %s", acadErrorStatusText( errorStatus ));
		delete xRefDWGDatabase;
		return false;
	}

	//Get the definition for the block in the the external reference
	errorStatus = xRefBlockTable-&amp;gt;getAt( moduleName, xRefBlockTableRecord, AcDb::kForRead );
	if( errorStatus != Acad::eOk )
	{
		acutPrintf(L"\nError could not get xref block table record %s", acadErrorStatusText( errorStatus ));     
		xRefBlockTable-&amp;gt;close();
		delete xRefDWGDatabase;
		return false;
	}
	
	xRefBlockTable-&amp;gt;close();

	errorStatus = xRefBlockTableRecord-&amp;gt;getBlockReferenceIds( blockIds );
	if( errorStatus != Acad::eOk )
	{
		acutPrintf(L"\nError could not get xref block ids %s", acadErrorStatusText( errorStatus ));     
		xRefBlockTableRecord-&amp;gt;close();
		delete xRefDWGDatabase;
		return false;
	}


	//Push all points into the vector
	for( int i = 0; i &amp;lt; blockIds.length(); i++ )
	{
		ent = NULL;
		acdbOpenObject( ent, blockIds.at(i), AcDb::kForRead );
		if( ent != NULL )
		{
			ref = NULL;
			ref = AcDbBlockReference::cast( ent );
			if( ref != NULL )
			{
				AcGePoint2d pnt;
				pnt.x = ref-&amp;gt;position().x;
				pnt.y = ref-&amp;gt;position().y;

				//Transfrom point
				pnt.x += xOffset;
				pnt.y += yOffset;
				points-&amp;gt;push_back( pnt );
			}
			ent-&amp;gt;close();
		}		
	}
	delete xRefDWGDatabase;
	xRefBlockTableRecord-&amp;gt;close();
	return true;
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Mar 2017 17:07:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976290#M8462</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-27T17:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding block references in external references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976301#M8463</link>
      <description>&lt;P&gt;Maybe it is dynamic block?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 17:10:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976301#M8463</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2017-03-27T17:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Finding block references in external references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976309#M8464</link>
      <description>&lt;P&gt;How would I check for a dynamic block?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 17:13:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976309#M8464</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-27T17:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: Finding block references in external references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976310#M8465</link>
      <description>&lt;H3 class="r"&gt;&lt;A href="http://adndevblog.typepad.com/autocad/2012/06/finding-all-block-references-of-a-dynamic-block.html" target="_blank"&gt;Finding all block references of a dynamic block &lt;/A&gt;&lt;/H3&gt;
&lt;P&gt;(hope you can translate this code from C# to ObjectARX) &lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 17:16:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976310#M8465</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2017-03-27T17:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding block references in external references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976314#M8466</link>
      <description>&lt;P&gt;Ok that looks promising I will play around with it and post back if it works out.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 17:16:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976314#M8466</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-27T17:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding block references in external references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976779#M8467</link>
      <description>&lt;P&gt;I have played around with some arx code and can now detect that there are "anonymous blocks" in the table usually labeled something like *U12 where the number will vary from block to block. Do you know where these anonymous blocks come from? in the article you linked they say "An anonymous block is created for each different state of the dynamic block" but I dont have any states in my blocks.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 20:10:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6976779#M8467</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-27T20:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Finding block references in external references</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6977016#M8468</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;...Do you know where these anonymous blocks come from? in the article you linked they say "An anonymous block is created for each different state of the dynamic block" but I dont have any states in my blocks...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the dynamic block has parameters, then changing any of the parameters results in the creation of an anonymous block.&lt;/P&gt;
&lt;P&gt;If you post a fragment of a dwg-file with such block, then I can explain in more detail. However, this does not apply to the main issue of this topic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 21:26:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/finding-block-references-in-external-references/m-p/6977016#M8468</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2017-03-27T21:26:29Z</dc:date>
    </item>
  </channel>
</rss>

