AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Active Contributor
M_Mogharabi
Posts: 26
Registered: ‎12-12-2011
Message 1 of 3 (143 Views)
Accepted Solution

inaccurate coordinates

143 Views, 2 Replies
02-17-2012 11:31 PM

hi all.

I'm developing an application in c# and I use sendcommand to draw shapes and write text in autocad.

I use lisp  to write text in autocad. here's an example :

ActiveDocument.SendCommand("(defun c:writeText() (Command \"text\" \"{0},{1}\" \"{2}\")));

ActiveDocument.SendCommand("writeText");

{0} and {1} are coordinates of the start of text and {2} is the text itself.

the problem is when text is drawn its start position is not what I passed to sendcommand SOMETIMES!

sometimes it is exactly written in the coordinate I specified, but sometimes it gets changed a little.

I checked autocad commandline and it recieves the parameters correctly everytime.

does anyone have any idea?

thanks in advance.

Hi,

 

depending on country settings it may me the decimal-separator that makes troubles. E.g. for us we have a comma as sep and if you send now the coords with your syntax the result for X=10.1 and Y=20.2 would be

10,1,20,2     instead of   10.1,20.2

for the definition for one point. So we would have first to replace the comma to a point before we send a double-value (converted to string) to the command-line.

 

The second reason (always critical when using points-coords in SendCommands) is the objectsnap. E.g. if you have a line from 0,0 to 10,10 and you try to set a text at point 1,1 the object-snap "ENDPOINT" will result in ==> the text is positioned at 0,0 (and not at 1,1). So deactivate osnap first.

 

- alfred -

*Expert Elite*
Alfred.NESWADBA
Posts: 9,574
Registered: ‎06-29-2007
Message 2 of 3 (142 Views)

Re: inaccurate coordinates

02-17-2012 11:40 PM in reply to: M_Mogharabi

Hi,

 

depending on country settings it may me the decimal-separator that makes troubles. E.g. for us we have a comma as sep and if you send now the coords with your syntax the result for X=10.1 and Y=20.2 would be

10,1,20,2     instead of   10.1,20.2

for the definition for one point. So we would have first to replace the comma to a point before we send a double-value (converted to string) to the command-line.

 

The second reason (always critical when using points-coords in SendCommands) is the objectsnap. E.g. if you have a line from 0,0 to 10,10 and you try to set a text at point 1,1 the object-snap "ENDPOINT" will result in ==> the text is positioned at 0,0 (and not at 1,1). So deactivate osnap first.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
M_Mogharabi
Posts: 26
Registered: ‎12-12-2011
Message 3 of 3 (135 Views)

Re: inaccurate coordinates

02-18-2012 12:58 AM in reply to: Alfred.NESWADBA

thank you very much.

disabling objectsnap resolved the issue.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.