<?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: Creation of a Simple Enity with an Anonymus Block as representation in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9560942#M4438</link>
    <description>&lt;P&gt;Fantastic&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp;, it works perfectly.&amp;nbsp;I wanted to do just that. I'd like to ask you one last thing: can I add to these cars a palette of personal characteristics such as color, number of seats etc ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 17:04:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-06-04T17:04:50Z</dc:date>
    <item>
      <title>Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9545150#M4425</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to create a simple Arx project containing a simple entity that has a graphical representation. Thanks to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp; I know that I should use the&amp;nbsp;&lt;SPAN&gt;AcDbBlockReferenc function but&lt;/SPAN&gt;&amp;nbsp;I'm not able to found any example on internet that could explain me how to achieve this. I should create a command that when is invoked from AutoCAD, it shows me a custom block, e.g. a car or a weel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 07:58:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9545150#M4425</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-28T07:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9545311#M4426</link>
      <description>&lt;P&gt;An AcDbBlockReference represents a block references (BREF) to a block, that contains entities.&lt;/P&gt;
&lt;P&gt;These are the basic steps to create an unnamed block and a BREF to it:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create an AcDbBlockTableRecord:&amp;nbsp; AcDbBlockTableRecord *btr = new AcDbBlockTableRecord;&lt;/LI&gt;
&lt;LI&gt;Name it "*U" to make it unnamed:&amp;nbsp;btr-&amp;gt;setName(L"*U");&lt;/LI&gt;
&lt;LI&gt;Populate btr with entities that represent you car (or whatever): btr-&amp;gt;appendAcDbEntity(newEntity)&lt;BR /&gt;Don't forget to newEntity-&amp;gt;close() after you appended it the btr.&lt;/LI&gt;
&lt;LI&gt;Add btr to the AcDbBlockTable of your AcDbDatabase and get its ID:&lt;BR /&gt;db-&amp;gt;getBlockTable(bt, kforWrite); bt-&amp;gt;add(ID, btr); btr-&amp;gt;close(); bt-&amp;gt;close();&lt;/LI&gt;
&lt;LI&gt;Create an AcDbBlockReference and to your btr and add it to the modelspace:&lt;BR /&gt;AcDbBlockReference *bref = new AcDbBlockReference; bref-&amp;gt;setBlockTableRecord(ID);&lt;BR /&gt;postToDb(bref);&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;See also these ARX samples:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;ArxDbgUtils::defineNewAnonymousBlock() in &amp;lt;ARX&amp;gt;\samples\database\ARXDBG&lt;/LI&gt;
&lt;LI&gt;void addBlockWithAttributes() in &amp;lt;ARX&amp;gt;\samples\database\complex_dg\complex.cpp&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 28 May 2020 09:11:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9545311#M4426</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-05-28T09:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9545353#M4427</link>
      <description>&lt;P&gt;At the beginning I've to create an Entity that has a graphical representation of my car ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 09:28:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9545353#M4427</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-28T09:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9546604#M4428</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;At the beginning I've to create an Entity that has a graphical representation of my car ?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You wrote that you want to represent your object (let's say a car) using a block reference (AcDbBlockReference, BREF).&lt;/P&gt;
&lt;P&gt;A BREF points to a block (AcDbBlockTableRecord, BTR) that holds AutoCAD entities that represent your car.&lt;/P&gt;
&lt;P&gt;If you want to create the representation of a car programmatically, you have to create 1..N entities that represent the car and put them into the BTR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also draw the car, engine, tire... blocks yourself and just load them into AutoCAD. But this is easier with named blocks. I have attached a very simple (and ugly) drawing of a car (car.dwg) that shows how you could assemble a car with blocks and a second one with four cars (cars.dwg).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;car.dwg
   Blocks: 
      cabin : 2 3DSOLIDs 
      engine: 1 3DSOLID 
      wheel:  2 3DSOLIDs 
   BREFs: 
      1 x cabin
      1 x engine
      4 x wheel
   
cars.dwg
   Blocks: 
      cabin : 2 3DSOLIDs 
      engine: 1 3DSOLID 
      wheel:  2 3DSOLIDs 
      car:   1 BREF to cabin, 1 BREF to engine, 4 BREFs to wheel
   BREFs: 
      4 x car&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 17:49:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9546604#M4428</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-05-28T17:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9546677#M4429</link>
      <description>&lt;P&gt;Thank you for your examples&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;unfortunately I have a lot of confusion in my head, my goal is to have a block for each element of the machine. then I would like a simple CREATE_CAR command that automatically draws a machine on the AutoCAD draw area, then a command CREAT_WHEEL that draw a wheel, even if these two are not connected for the moment. I can't find a basic example of an ARX project to create such a thing. I hope you can recommend something to follow to get started.&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 18:23:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9546677#M4429</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-28T18:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9548319#M4430</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like a simple CREATE_CAR command that automatically draws a machine on the AutoCAD draw area (..)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do you mean by "automatically draw a machine"?&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Insertion of a block reference to a &lt;U&gt;predefined&lt;/U&gt; block that contains a machine? &amp;nbsp; or&lt;/LI&gt;
&lt;LI&gt;Shall the machine itself be drawn programmatically? &lt;BR /&gt;I.e. using same parameters like number of cylinders, power etc.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;So for case 1: Lets say you have predifined blocks of&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;some car bodies:&amp;nbsp; body_ferrari, body_porsche&lt;/LI&gt;
&lt;LI&gt;some engines: engine100kw, engine150kw, engine200kw&lt;/LI&gt;
&lt;LI&gt;some wheels: wheel205, wheel195&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Do you want a function like:&amp;nbsp; buildCar("body_ferrari", "engine150kw", "wheel205"); ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For case 2 you would need function that create your blocks.&lt;/P&gt;
&lt;P&gt;CreateBodyBlock("body_ferrari", "ferrari");&lt;/P&gt;
&lt;P&gt;CreateEngineBlock("engine150kw", 150);&lt;/P&gt;
&lt;P&gt;CreateWheelBlock("wheel205", 205);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you think about the DWGs I attached? Is this what you want to create in principle?&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 12:02:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9548319#M4430</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-05-29T12:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9549399#M4431</link>
      <description>&lt;P&gt;Yes &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp;, I'd like to create something like 2nd situation. I want to have some different graphical representation for eacg block. eg. a car, a wheel, an engine and so on.... I'd like to have a command like DRAW_CAR and the in the Autocad's draw should appear a car, like in 1st photos I attached. After I'd like to have a command like DRAW_ENGINE and the engine should appear on the draw. 2nd attached photos and so on .....&amp;nbsp; . This commands should use a defined block like elements in your car.dwg. Each element should be create in a different moment and for the moment can not be related. If i call another time the DRAW_WHEEL , another wheel should be displayed&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wheel.png" style="width: 912px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779292i57D5F75A37117BE3/image-size/large?v=v2&amp;amp;px=999" role="button" title="wheel.png" alt="wheel.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="engine.png" style="width: 822px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779293i3E356B2AA728E109/image-size/large?v=v2&amp;amp;px=999" role="button" title="engine.png" alt="engine.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="car.png" style="width: 658px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779294i1220913617C2AF85/image-size/large?v=v2&amp;amp;px=999" role="button" title="car.png" alt="car.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thx,&lt;/P&gt;
&lt;P&gt;Marco&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:04:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9549399#M4431</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-03T13:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9550717#M4432</link>
      <description>&lt;P&gt;Here is some sample code. You can register the function&amp;nbsp; cmdDrawCar()&amp;nbsp; as command DRAW_CAR.&lt;/P&gt;
&lt;P&gt;It uses a simple class BlockDrawCar that "draws" a car into an AcDbBlockTableRecord.&lt;/P&gt;
&lt;P&gt;You can modify the code in cmdDrawCar() to either create unnamed blocks or a named block that will be reused.&lt;/P&gt;
&lt;P&gt;Please familiarize yourself with the concept of named an unnamed blocks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;class BlockDrawCar
{
public:
	void DrawBlock(AcDbBlockTableRecord *btr)
	{
		Acad::ErrorStatus es;

		// Draw a rectangle polyline
		AcDbPolyline *pline = new AcDbPolyline();
		AcGePoint2d p0(0.0, 0.0), p1(m_Length, 0.0);
		AcGePoint2d p2(m_Length, m_Width), p3(0.0, m_Width);
		pline-&amp;gt;addVertexAt(0, p0);
		pline-&amp;gt;addVertexAt(1, p1);
		pline-&amp;gt;addVertexAt(2, p2);
		pline-&amp;gt;addVertexAt(3, p3);
		pline-&amp;gt;setClosed(true);
		pline-&amp;gt;setDatabaseDefaults();
		pline-&amp;gt;setColorIndex(m_Color);
		es = btr-&amp;gt;appendAcDbEntity(pline);
		if (!es)
			pline-&amp;gt;close();
		else
			delete pline;

		// Draw a circle
		AcDbCircle *circle = new AcDbCircle();
		AcGePoint3d center(m_Width / 2, m_Width / 2, 0.0);
		double radius = m_Width * 0.4;
		circle-&amp;gt;setCenter(center);
		circle-&amp;gt;setRadius(radius);
		circle-&amp;gt;setDatabaseDefaults();
		circle-&amp;gt;setColorIndex(m_Color);
		es = btr-&amp;gt;appendAcDbEntity(circle);
		if (!es)
			circle-&amp;gt;close();
		else
			delete circle;
	}

public:
	int m_Color=7;
	double m_Width=200;
	double m_Length=340;
};


AcDbObjectId CreateCarBlock(AcDbDatabase *db, LPCWSTR blockname)
{
	Acad::ErrorStatus es;
	AcDbBlockTableRecord *btr = new AcDbBlockTableRecord;
	BlockDrawCar *car = new BlockDrawCar;
	car-&amp;gt;DrawBlock(btr);
	btr-&amp;gt;setName(blockname);

	// Add the BTR to the Blocktable of the current drawing
	AcDbObjectId BtrID;
	AcDbBlockTable *blocktable;
	es = db-&amp;gt;getBlockTable(blocktable, AcDb::kForWrite);
	if (!es)
	{
		es = blocktable-&amp;gt;add(BtrID, btr);
		if (!es)
			btr-&amp;gt;close();
		else
			delete btr;
		blocktable-&amp;gt;close();
	}

	return BtrID;
}

AcDbObjectId FindBlock(AcDbDatabase *db, LPCWSTR blockname)
{
	AcDbObjectId BlockID;
	Acad::ErrorStatus es;
	AcDbBlockTable *blocktable;
	es = db-&amp;gt;getBlockTable(blocktable, AcDb::kForRead);
	if (!es)
	{
		es = blocktable-&amp;gt;getAt(blockname, BlockID);
		blocktable-&amp;gt;close();
	}
	return BlockID;
}

Acad::ErrorStatus PostToDb(AcDbDatabase *db, AcDbObjectId&amp;amp; objId, AcDbEntity* pEnt)
{
	Acad::ErrorStatus      es;
	AcDbBlockTable*        blocktable = 0;
	AcDbBlockTableRecord*  modelspace = 0;

	if ((es = db-&amp;gt;getBlockTable(blocktable, AcDb::kForRead)) != Acad::eOk)
		return es;

	if ((es = blocktable-&amp;gt;getAt(ACDB_MODEL_SPACE, modelspace, AcDb::kForWrite)) == Acad::eOk)
	{
		es = modelspace-&amp;gt;appendAcDbEntity(objId, pEnt);
		modelspace-&amp;gt;close();
	}
	blocktable-&amp;gt;close();

	return es;
}

void cmdDrawCar()
{
	Acad::ErrorStatus es;
	LPCWSTR blockname = L"*U"; // Blockname. This is for an unnamed block.
	blockname = L"car"; // And this for a named block

	AcDbDatabase *db = acdbHostApplicationServices()-&amp;gt;workingDatabase();
	AcDbObjectId BtrID;
	if (blockname[0]!=L'*') // '*' as first char means: Unnamed block. Don't search for it.
		BtrID = FindBlock(db, blockname); // Search for an existing named block 

	if (BtrID.isNull())
		BtrID = CreateCarBlock(db, blockname); // For "*U" AutoCAD will create unique names like "*U1", "*U2", ...

	if (BtrID.isNull())
	{
		acutPrintf(L"\nFailed.");
		return;
	}

	// Now create a block reference
	AcDbBlockReference *bref = new AcDbBlockReference;
	bref-&amp;gt;setDatabaseDefaults();
	bref-&amp;gt;setBlockTableRecord(BtrID);

	AcGeVector3d insertionPoint;
	acedGetPoint(nullptr, L"\nInsertion point: ", asDblArray(insertionPoint));
	AcGeMatrix3d trans; // the transformation matrix
	trans.setToTranslation(insertionPoint);
	bref-&amp;gt;setBlockTransform(trans);

	// Append it to modelspace
	AcDbObjectId BrefID;
	es = PostToDb(db, BrefID, bref);
	if (!es)
		bref-&amp;gt;close();
	else
		delete bref;
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 May 2020 21:26:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9550717#M4432</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-05-30T21:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9554088#M4433</link>
      <description>&lt;P&gt;There is a memory leak in&amp;nbsp; &lt;FONT face="courier new,courier"&gt;CreateCarBlock(AcDbDatabase *db, LPCWSTR blockname)&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Either change the code to&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;	BlockDrawCar car;
	car.DrawBlock(btr);&lt;/LI-CODE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;	BlockDrawCar *car = new BlockDrawCar;
	car-&amp;gt;DrawBlock(btr);
	delete car;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 07:06:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9554088#M4433</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-06-02T07:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9555760#M4434</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I read your example, should be very useful, thank you very very much. But I'm not understanding how to run it. I've generated an ARX project by the Objectarx wizard and added all your code in a file named BlockDrawCar.cpp. I've added dependencies to ObjectArx inc/inx64 and lib folders. But I got dependencies erros. I'm attaching a photo of my editor.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dep-errprs.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/779295iCA12126BC57064A0/image-size/large?v=v2&amp;amp;px=999" role="button" title="dep-errprs.png" alt="dep-errprs.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:05:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9555760#M4434</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-03T13:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9557673#M4435</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;(..) I got dependencies erros. I'm attaching a photo of my editor.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Add #include "stdafx.h" as first line in the source file.&lt;/P&gt;
&lt;P&gt;This is the "precompiled header file" that VS is complaining about in "unexpected end of file...".&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;I'm not understanding how to run it. I've generated an ARX project by the Objectarx wizard and added all your code in a file named BlockDrawCar.cpp. &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have to register&amp;nbsp; void cmdDrawCar()&amp;nbsp;&amp;nbsp; as command.&lt;/P&gt;
&lt;P&gt;The ARX Wizard creates a file named acrxEntryPoint.cpp where some sample commands are registered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;class CArxProjectTestApp : public AcRxArxApp {
	static void XXXXMyGroupMyCommand() {
	   // Put your command code here. I.e. call cmdDrawCar()
	}
}
// This macro actually registers void XXXXMyGroupMyCommand()
// as command "MyCommand" and "MyCommandLocal":
ACED_ARXCOMMAND_ENTRY_AUTO(CArxProjectTestApp, XXXXMyGroup, MyCommand, MyCommandLocal, ACRX_CMD_MODAL, NULL)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to register a command "DRAW_CAR" you would add:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;class CArxProjectTestApp : public AcRxArxApp {
	static void XXXXMyGroupDRAW_CAR() {
	   cmdDrawCar();
	}
}

ACED_ARXCOMMAND_ENTRY_AUTO(CArxProjectTestApp, XXXXMyGroup, DRAW_CAR, DISEGNA_AUTO, ACRX_CMD_MODAL, NULL)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Jun 2020 13:34:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9557673#M4435</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-06-03T13:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9558255#M4436</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp; it works &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;the sample is perfect, i'd like to add only another thing. How can I replace the DrawBlockFunction with a certain block that I've already defined, e.g. with the block of the car in the .dwg that you posted before ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 16:58:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9558255#M4436</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-03T16:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9559547#M4437</link>
      <description>&lt;P&gt;It's already in the sample code.&lt;/P&gt;
&lt;P&gt;The first call of cmdDrawCar()&amp;nbsp; creates the block "car".&lt;/P&gt;
&lt;P&gt;If you call cmdDrawCar()&amp;nbsp; again, it will use the existing block "car" and simply create another BREF to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you mean how you can load a block from an external DWG?&lt;/P&gt;
&lt;P&gt;This can be done like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;AcDbObjectId insertDwgAsBlock(AcDbDatabase *pTargetDb, LPCWSTR dwgFilePath, LPCWSTR blockname)
{
	AcDbObjectId BtrID; // The resulting Id of the AcDbBlockTableRecordd
	Acad::ErrorStatus es;

	//----- Read the external DWG file
	AcDbDatabase *pDwg = new AcDbDatabase( Adesk::kFalse );	
	es = pDwg-&amp;gt;readDwgFile(dwgFilePath);

	//----- Insert it into the current Database
	if (!es)
		es = pTargetDb-&amp;gt;insert(BtrID, blockName, pDwg, true);
	delete pDwg;	
	return BtrID;
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With db and BtrID from the code above you can use it like this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;	BtrID = insertDwgAsBlock(db, L"C:\\blocks\\car.dwg", L"car");&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 07:27:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9559547#M4437</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-06-04T07:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9560942#M4438</link>
      <description>&lt;P&gt;Fantastic&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp;, it works perfectly.&amp;nbsp;I wanted to do just that. I'd like to ask you one last thing: can I add to these cars a palette of personal characteristics such as color, number of seats etc ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:04:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9560942#M4438</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-04T17:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566432#M4439</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;can I add to these cars a palette of personal characteristics such as color, number of seats etc ? &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes to both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding colors I would recomment to use AutoCAD's color logic for blocks and entities.&lt;/P&gt;
&lt;P&gt;Beside the "regular" RGB or color-index colors there are the special index colors values "fromBlock"=0 and "fromLayer"=256. See docs on AcDbColor and AcCmColor for details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding other characteristics there are different ways to implement them.&amp;nbsp; You can add custom data to AcDbObjects by &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Adding XData (see AcDbObject::setXData(..))&lt;/LI&gt;
&lt;LI&gt;Adding XRecords in the extension dictionary of an AcDbObject (see class AcDbXrecord and the AcDbObject methods&amp;nbsp;extensionDictionary() and createExtensionDictionary())&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You might want to read the ARX docs about "Protocol Extension" or ways to use COM to implement "Static or Dynamic Properties" and interact with the OPM (Object Property Manager).&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 09:38:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566432#M4439</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-06-08T09:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566444#M4440</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp; in your opinion which solution is easier? Can you show me a quick sample ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx, Marco&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 09:42:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566444#M4440</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-08T09:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566502#M4441</link>
      <description>&lt;P&gt;XData is easier to use, but limited to 16kb Data. Allowed "restypes" are in the range 1000-1071.&lt;/P&gt;
&lt;P&gt;XRecord have a bit more overhead but less limitations. They allow restypes in the range &lt;STRONG&gt;1-369 (except 5 and 105)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Both are based on resbuf-lists that contain the data. A resbuf list is a linked list:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;struct resbuf {                                                  
        struct resbuf *rbnext; // Allows them to be "linked"
        short restype;
        union ads_u_val resval;
};&lt;/LI-CODE&gt;
&lt;P&gt;The restypes defines which component of the &lt;FONT face="courier new,courier"&gt;union resval&lt;/FONT&gt; is valid.&lt;/P&gt;
&lt;P&gt;Sample:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;LPCWSTR myAppName=L"MYAPP";

void setCarXData(AcDbBlockReference *brefCar) // brefCar must be open for write
{
	acdbRegApp(myAppName); // Make sure your XData appname is registered

	resbuf *rb = acutBuildList(
		AcDb::kDxfRegAppName, myAppName,
		AcDb::kDxfXdAsciiString, L"Car",
		AcDb::kDxfXdControlString, L("{"),
		  AcDb::kDxfXdAsciiString, L"Lamborghini", //name
		  AcDb::kDxfXdReal,	250.0,				   //max speed
		  AcDb::kDxfXdInteger16,	2,			   //number of seats
		AcDb::kDxfXdControlString, L("}"),
		0
	);
	brefCar-&amp;gt;setXData(rb); // this will replace the XData for myAppName
	acutRelRb(rb); // release the list.
}

void getCarXData(AcDbBlockReference *brefCar) // brefCar must be open for read
{
	resbuf *rb = brefCar-&amp;gt;XData(myAppName);  // get XData for myAppName
	// -- use rb here --
	acutRelRb(rb); // release the list.
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can look at XData of entities using ArxDbg.arx with command SNOOPENTS or SNOOPDB and hit [Xdata...]&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 10:13:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566502#M4441</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-06-08T10:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566533#M4442</link>
      <description>&lt;P&gt;I think that for my purposes Xdata data limit can be useful. But I'm not understanding: this properties can by edited in Autocad implemeting in the future a Dialog to show a palette like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brand: Lamborghini&lt;/P&gt;&lt;P&gt;Seats: 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 10:29:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566533#M4442</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-08T10:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566763#M4443</link>
      <description>&lt;P&gt;Your dialog must retrieve and interprete the Xdata and display it to the user.&lt;/P&gt;
&lt;P&gt;When the user has changed some values and leaves the dialog with [OK], you have to create a new resbuf list with the updated values and replace the existing rebuf list with the new one.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 12:28:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9566763#M4443</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2020-06-08T12:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creation of a Simple Enity with an Anonymus Block as representation</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9567123#M4444</link>
      <description>&lt;P&gt;Dialogs should be implemented with objectARX ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 14:46:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/creation-of-a-simple-enity-with-an-anonymus-block-as/m-p/9567123#M4444</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-08T14:46:09Z</dc:date>
    </item>
  </channel>
</rss>

