<?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: Line drawing : Sending points from sendMessage to Autocad in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7514264#M7490</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;no reason, this was the method i saw on internet , and used it.&lt;/P&gt;
&lt;P&gt;Added ' ' (single space) not working with COPYDATASTRUCT.&lt;/P&gt;
&lt;P&gt;Could you please give me example of doing it by database method.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would recomment to use&amp;nbsp;&lt;FONT face="courier new,courier"&gt;acDocManager-&amp;gt;sendStringToExecute(&lt;/FONT&gt;)&amp;nbsp; instead of &lt;FONT face="courier new,courier"&gt;SendMessage(hwnd, WM_COPYDATA, ..)&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;But you should always prefer to create objects directly in the database, because it gives you &lt;U&gt;much&lt;/U&gt; better control and performance than sending commands! Sending "_LINE 0,0,0 100,0,0 \n" to AutoCAD doesn't guarantee that it really draws a line from 0,0,0 to 100,0,0. There might be object snap involved causing a totally different start- or endpoints to be snapped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// Add entity ent to the modelspace of the current drawing.
Acad::ErrorStatus postToDb(AcDbEntity* ent, AcDbObjectId&amp;amp; objId)
{
	Acad::ErrorStatus      es;
	AcDbBlockTableRecord *pModelSpace;
	AcDbDatabase *pDB = acdbHostApplicationServices()-&amp;gt;workingDatabase();
	AcDbObjectId IdModelSpace = acdbSymUtil()-&amp;gt;blockModelSpaceId(pDB);

	if ((es = acdbOpenObject(pModelSpace, IdModelSpace, AcDb::kForWrite)) == Acad::eOk) 
	{
		es = pModelSpace-&amp;gt;appendAcDbEntity(objId, ent);
		pModelSpace-&amp;gt;close();

		if (es == Acad::eOk)
			ent-&amp;gt;close();
	}
	return es;
}

// Create a line in the modelspace of the current drawing.
AcDbObjectId AddLine(AcGePoint3d p1, AcGePoint3d p2)
{
	AcDbObjectId objId;
	AcDbLine *line = new AcDbLine(p1, p2);
	line-&amp;gt;setDatabaseDefaults();
	Acad::ErrorStatus es = postToDb(line, objId);
	if (es != Acad::eOk)
		delete line;
	return objId;
}&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Nov 2017 08:36:29 GMT</pubDate>
    <dc:creator>tbrammer</dc:creator>
    <dc:date>2017-11-03T08:36:29Z</dc:date>
    <item>
      <title>Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7506868#M7486</link>
      <description>&lt;P&gt;HI All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have *.arx, which i am loading into Autocad using appload *.arx file.&lt;/P&gt;&lt;P&gt;I intend to draw a line by using&amp;nbsp;&lt;SPAN&gt;SendCmdToAcad&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;read(string cmd )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;wchar_t wptr[50] = {0};&lt;BR /&gt;cmd += "\n";&lt;BR /&gt;char2wchar(cmd.c_str(), wptr);&lt;BR /&gt;SendCmdToAcad(wptr);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;static void SendCmdToAcad(ACHAR *cmd)&lt;BR /&gt;{&lt;BR /&gt;COPYDATASTRUCT cmdMsg;&lt;BR /&gt;cmdMsg.dwData = (DWORD)1;&lt;BR /&gt;cmdMsg.cbData = (DWORD)(_tcslen(cmd) + 1) * sizeof(ACHAR);&lt;BR /&gt;cmdMsg.lpData = cmd;&lt;BR /&gt;HWND hwnd = adsw_acadMainWnd();&lt;BR /&gt;SendMessage(hwnd, WM_COPYDATA, NULL, (LPARAM)&amp;amp;cmdMsg);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sequence is&lt;/P&gt;&lt;P&gt;command: _line&amp;nbsp; &amp;nbsp;-&amp;gt;&amp;nbsp;&lt;SPAN&gt;SendMessage() works fine sends to autocad and&amp;nbsp;SendMessage() returns from call&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Specify first point: 10,20,0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Specify next point or [Undo]:&amp;nbsp; &amp;nbsp;: After sending 1st point sendmessage blocks here , does not return from the call, until i explicitly hit "ENTER" key on Autocad window.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How do i solve the problem programmatically of hitting "enter" key after point.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In my read() -&amp;gt; above If i do&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;cmd += "\n\n";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;then it escapes reading the second point as well&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Specify next point or [Undo]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please let me know, any pointers would be greatly appreciated.&amp;nbsp;I need to get this done.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Observed Behaviour&lt;/P&gt;&lt;P&gt;10,20,30\0 : reads point on same line as in (10,20,30|123,300,10)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; no | in real life just indicative of end of 1 point&lt;BR /&gt;10,20,30\n : blocks&lt;BR /&gt;10,20,30\n\n : skips the next point reading&lt;BR /&gt;10,20,30(1char)\n: if (1char) any character is added it goes fine, but point becomes invalid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 04:23:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7506868#M7486</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-01T04:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7511379#M7487</link>
      <description>&lt;P&gt;Have you tried to use &lt;FONT face="courier new,courier"&gt;acDocManager-&amp;gt;sendStringToExecute(doc, command)&lt;/FONT&gt;&amp;nbsp; instead?&lt;/P&gt;
&lt;P&gt;This works fine for me:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;acDocManager-&amp;gt;sendStringToExecute(acDocManager-&amp;gt;curDocument(), L"_LINE 10,0,0 10,20,0 \n");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I use one space ' ' to terminate the point and a '&lt;FONT face="courier new,courier"&gt;\n&lt;/FONT&gt;' to terminate the LINE command.&lt;/P&gt;
&lt;P&gt;Maybe it also works for the COPYDATASTRUCT approach.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 13:22:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7511379#M7487</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-11-02T13:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7511382#M7488</link>
      <description>&lt;P&gt;By the way: Is there a special reason why you draw a line like this instead of creating in directly in the database?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 13:24:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7511382#M7488</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-11-02T13:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7513951#M7489</link>
      <description>&lt;P&gt;no reason, this was the method i saw on internet , and used it.&lt;/P&gt;&lt;P&gt;Added ' ' (single space) not working with COPYDATASTRUCT.&lt;/P&gt;&lt;P&gt;Could you please give me example of doing it by database method.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 04:03:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7513951#M7489</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-03T04:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7514264#M7490</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;no reason, this was the method i saw on internet , and used it.&lt;/P&gt;
&lt;P&gt;Added ' ' (single space) not working with COPYDATASTRUCT.&lt;/P&gt;
&lt;P&gt;Could you please give me example of doing it by database method.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would recomment to use&amp;nbsp;&lt;FONT face="courier new,courier"&gt;acDocManager-&amp;gt;sendStringToExecute(&lt;/FONT&gt;)&amp;nbsp; instead of &lt;FONT face="courier new,courier"&gt;SendMessage(hwnd, WM_COPYDATA, ..)&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;But you should always prefer to create objects directly in the database, because it gives you &lt;U&gt;much&lt;/U&gt; better control and performance than sending commands! Sending "_LINE 0,0,0 100,0,0 \n" to AutoCAD doesn't guarantee that it really draws a line from 0,0,0 to 100,0,0. There might be object snap involved causing a totally different start- or endpoints to be snapped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// Add entity ent to the modelspace of the current drawing.
Acad::ErrorStatus postToDb(AcDbEntity* ent, AcDbObjectId&amp;amp; objId)
{
	Acad::ErrorStatus      es;
	AcDbBlockTableRecord *pModelSpace;
	AcDbDatabase *pDB = acdbHostApplicationServices()-&amp;gt;workingDatabase();
	AcDbObjectId IdModelSpace = acdbSymUtil()-&amp;gt;blockModelSpaceId(pDB);

	if ((es = acdbOpenObject(pModelSpace, IdModelSpace, AcDb::kForWrite)) == Acad::eOk) 
	{
		es = pModelSpace-&amp;gt;appendAcDbEntity(objId, ent);
		pModelSpace-&amp;gt;close();

		if (es == Acad::eOk)
			ent-&amp;gt;close();
	}
	return es;
}

// Create a line in the modelspace of the current drawing.
AcDbObjectId AddLine(AcGePoint3d p1, AcGePoint3d p2)
{
	AcDbObjectId objId;
	AcDbLine *line = new AcDbLine(p1, p2);
	line-&amp;gt;setDatabaseDefaults();
	Acad::ErrorStatus es = postToDb(line, objId);
	if (es != Acad::eOk)
		delete line;
	return objId;
}&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Nov 2017 08:36:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7514264#M7490</guid>
      <dc:creator>tbrammer</dc:creator>
      <dc:date>2017-11-03T08:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7514482#M7491</link>
      <description>&lt;P&gt;Thank you tbrammer.&lt;/P&gt;&lt;P&gt;I also need to capture the mouse event clicked on line/symbol/text entities.&lt;/P&gt;&lt;P&gt;Could you please direct me to sample code of doing it.&lt;/P&gt;&lt;P&gt;Ive posted a question on this with title "C++: Mouse Event handling"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2017 10:16:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7514482#M7491</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-03T10:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7567802#M7492</link>
      <description>&lt;P&gt;I need to send points to Autocad through Sendmessage(), but stuck&lt;/P&gt;&lt;P&gt;with not able to send points to autocad, due to the listed problem in my query.&lt;/P&gt;&lt;P&gt;If anybody knows any workaround to send points to autocad using sendmessage, please let me know,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 10:11:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7567802#M7492</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-23T10:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7577802#M7493</link>
      <description>&lt;P&gt;This way also it works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;string&amp;nbsp;&lt;SPAN&gt;AutoCmd="1234556.89,6823463,50,50";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;wchar_t *wpt = (wchar_t *)calloc(AutoCmd.length(), sizeof(wchar_t));&lt;BR /&gt;char2wchar(&lt;SPAN&gt;AutoCmd&lt;/SPAN&gt;.c_str(), wpt);&lt;BR /&gt;acedCommand(RTSTR, _T("_POINT"), RTSTR, wpt , RTNONE);&lt;BR /&gt;free(wpt);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 09:46:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7577802#M7493</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-28T09:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Line drawing : Sending points from sendMessage to Autocad</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7577843#M7494</link>
      <description>&lt;P&gt;I recommend you to follow&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/845950"&gt;@tbrammer&lt;/a&gt;&amp;nbsp;solution.&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;Please note your code might be work, but you will be not able to scale or migrate to newer versions of AutoCAD, your application may not work post fiber world. i/e ACAD 2015.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 09:58:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/line-drawing-sending-points-from-sendmessage-to-autocad/m-p/7577843#M7494</guid>
      <dc:creator>moogalm</dc:creator>
      <dc:date>2017-11-28T09:58:47Z</dc:date>
    </item>
  </channel>
</rss>

