Jump to content

Recommended Posts

Posted

I write machine control software in C - directly generating stripped down simple DXF files in R12 export format.

 

Normally only LINE and ARC functions are required as the output is a series of enclosed convex polygons consisting of straight lines, arcs.

 

For one application, I have been requested to add a label to each polygon in its centre.

 

I need a basic AutoCAD command that writes text to an X,Y coordinate position, and that is R12 compatible.

 

Thanks.

Posted

I believe this AutoLISP command will work:

 

(command "._text" '([color=red]xCoord[/color] [color=red]yCoord[/color]) [color=red]TextHeight[/color] [color=red]RotationAngle[/color] [color=red]TextString[/color] "" "")

 

 

Just replace the red place holders with the described values you require.

Posted

That lisp will insert a piece of string using the current text style. Since the text style may or may not contain the text height, a problem will occur if Autolisp doesn't send the data as are expected.

Johnggold, it must be an AutoCAD command? If you write the file with your C program and assuming we are talking about an ASCII dxf file, you could put in something like this:

(0 . "TEXT")

(1 . "Blah-blah... content goes here")

(8 . "Layer name")

(10 Xposition Yposition)

 

For short text, this is the shortest DXF lisp (I think). There is no Zpozition in the last line, you asked for R12.

 

I didn't test it, but it should work.

Posted

Thanks. I will try that. zposition is not needed as its all 2D.

Posted

In the mean time I tested the solution I proposed. Well, the information is correct, but the topic is "AutoLisp like". With other words: it will not work in that form. Try this:

  0
TEXT
10
Xpos
20
Ypos
 1
text goes here

Searching for the minimal code, I see that also it worked without the layer code. The text goes on the layer 0

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...