<?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: IntersectWith  XREF entities in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707391#M12946</link>
    <description>&lt;P&gt;Xref entities (actually any&amp;nbsp;entities in a block)&amp;nbsp;are transformed by&amp;nbsp;a AcDbBlockReference entity before being displayed. If you want to calculate an intersection, you need to account for that transformation.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Dec 2013 14:05:29 GMT</pubDate>
    <dc:creator>owenwengerd</dc:creator>
    <dc:date>2013-12-20T14:05:29Z</dc:date>
    <item>
      <title>IntersectWith  XREF entities</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707301#M12945</link>
      <description>&lt;P&gt;I'm trying to find intersections between current drawing entities, and attached XREF entities.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I have made a function that enumerates all curve entities in the current drawing + &amp;nbsp;XREF curve entities.&lt;/P&gt;&lt;P&gt;I'm using&amp;nbsp;acedSSGet with :n and later&amp;nbsp;acedSSNameX for iterating through nested entities, that is entities inside XREF.&lt;/P&gt;&lt;P&gt;So far so good, I got the objectIds, but when I try to call intersectWith, I get no intersection points, and intersectWith returns eOk.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code, I do not know what else to try.&lt;/P&gt;&lt;PRE&gt;static void multi_select_nested_entity(AcDbObjectIdArray &amp;amp;iaElementsInXref)
{
	// switch on the multi selection of nested entities
	setAllowDuplicateSelection(curDoc(), true);   
	curDoc()-&amp;gt;inputPointManager()-&amp;gt;turnOnSubentityWindowSelection();
	ads_name sset, eName;
	AcDbObjectId id;

	// in the mode "_:n" 
	//
	if (RTNORM == acedSSGet(L"_:n", NULL, NULL, NULL, sset))
	{
		std::set&amp;lt;AcDbObjectId&amp;gt; setIds;
		acutPrintf(L"\n");
		long len = 0;
		acedSSLength(sset, &amp;amp;len);
		for (long i = 0; i &amp;lt; len; i++)
		{             
			resbuf *rb = NULL;
			//  ssnamex() returns all selected nested entities
			//  
			if (RTNORM == acedSSNameX(&amp;amp;rb, sset, i))
			{
				resbuf *rbWalk = rb;
				while (NULL != rbWalk)
				{
					if (RTENAME == rbWalk-&amp;gt;restype)
					{
						eName[0] = rbWalk-&amp;gt;resval.rlname[0];
						eName[1] = rbWalk-&amp;gt;resval.rlname[1];
							if (Acad::eOk == acdbGetObjectId(id, eName))
						{
//							acutPrintf(L"Entity %d: %x",i,id.asOldId());
							
							AcDbEntity *pEnt;
								if (Acad::eOk ==acdbOpenObject(pEnt,id,AcDb::kForRead))
							{
								if (pEnt-&amp;gt;isKindOf(AcDbCurve::desc()))
								{
									acutPrintf(L"From XREF: (%s)\n", pEnt-&amp;gt;isA()-&amp;gt;name());                           
										setIds.insert(id);
								}								
									pEnt-&amp;gt;close();
							}
							else
							{
								acutPrintf(L"\nCouldn't open object");
							}
						}
						//rbWalk = NULL; 
					}
					//else
					{
						rbWalk = rbWalk-&amp;gt;rbnext;
					}
				}
				acutRelRb(rb);
			}
		}
		acedSSFree(sset);

		set&amp;lt;AcDbObjectId&amp;gt;::iterator it;
			for (it = setIds.begin(); it != setIds.end(); ++it)
		{
			iaElementsInXref.append(*it);
		}
	} 
		// swtich off
	setAllowDuplicateSelection(curDoc(), false);
	curDoc()-&amp;gt;inputPointManager()-&amp;gt;turnOffSubentityWindowSelection();
		
}

// - ARSXTestXrefIntersect.test command (do not rename)
static void ARSXTestXrefIntersecttest(void)
{
	AcDbObjectIdArray iaElementsInXref;
	//find all entities
	multi_select_nested_entity(iaElementsInXref);
	for (int i=0; i &amp;lt; iaElementsInXref.length(); i++)
	{
		AcDbEntity *ptrEntA;
		if (acdbOpenAcDbEntity(ptrEntA, iaElementsInXref[i], AcDb::kForRead)==eOk)
		{
			for (int j = i + 1; j &amp;lt; iaElementsInXref.length(); j++)
			{
				AcDbEntity *ptrEntB;
				if (acdbOpenAcDbEntity(ptrEntB, iaElementsInXref[j], AcDb::kForRead)==eOk)
				{
					AcGePoint3dArray points;
					if (ptrEntA-&amp;gt;intersectWith(ptrEntB, kOnBothOperands, points)==Acad::eOk)
					{
						for (int k=0; k &amp;lt; points.length(); k++)
						{
							//CARSCDraw::circle(points[k], k+1, AcGeVector3d(0,0,1));
							acutPrintf(L"\nIntersection found at x=%.4f, y=%.4f", points[k].x, points[k].y);
						}
					}
					ptrEntB-&amp;gt;close();
				}					
			}
			ptrEntA-&amp;gt;close();
		}
	}
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2013 13:25:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707301#M12945</guid>
      <dc:creator>damir_vidakovic</dc:creator>
      <dc:date>2013-12-20T13:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: IntersectWith  XREF entities</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707391#M12946</link>
      <description>&lt;P&gt;Xref entities (actually any&amp;nbsp;entities in a block)&amp;nbsp;are transformed by&amp;nbsp;a AcDbBlockReference entity before being displayed. If you want to calculate an intersection, you need to account for that transformation.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2013 14:05:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707391#M12946</guid>
      <dc:creator>owenwengerd</dc:creator>
      <dc:date>2013-12-20T14:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: IntersectWith  XREF entities</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707431#M12947</link>
      <description>Do you mean I have to transform the entities by transformation matrix before the intersectWith call?</description>
      <pubDate>Fri, 20 Dec 2013 14:26:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707431#M12947</guid>
      <dc:creator>damir_vidakovic</dc:creator>
      <dc:date>2013-12-20T14:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: IntersectWith  XREF entities</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707469#M12948</link>
      <description>Yes, that is it! If I move insert point of XREF to the 0,0 I get correct intersections. I believe I'll have to transform entities considering UCS from XREF to get correct results for every XREF.</description>
      <pubDate>Fri, 20 Dec 2013 14:45:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707469#M12948</guid>
      <dc:creator>damir_vidakovic</dc:creator>
      <dc:date>2013-12-20T14:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: IntersectWith  XREF entities</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707721#M12949</link>
      <description>&lt;P&gt;If you're not worried about performance, you&amp;nbsp;may be able to&amp;nbsp;use AcDbBlockReference::explode() to create transformed copies of the entities.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2013 16:25:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/intersectwith-xref-entities/m-p/4707721#M12949</guid>
      <dc:creator>owenwengerd</dc:creator>
      <dc:date>2013-12-20T16:25:23Z</dc:date>
    </item>
  </channel>
</rss>

