PDA

View Full Version : nxn squares

nepenthe
10th Jun 2005, 05:02 pm
hello..
i've just started autolisp..i want to draw a box..thats not problem..i learned how to do it.
now i want to divide the box into nxn little squares.could you please help me with this problem...

thanks..

CarlB
10th Jun 2005, 05:58 pm
To draw the box you must know the coordinates of the four corners, or at least 2 opposite corners. From this calculate the width and height of the box. Divide each by 'n' to get the width and height of the little squares. Now draw all the horizontal and vertical lines, by starting at one corner and incrementing the x and y coordinates for each line. The 'repeat' function would work well for this.

nepenthe
10th Jun 2005, 10:11 pm
thanks CarlB
i just coded what you said in the message and it works well..
now i have another problem. i want to find all intersection points and write(print to the screen) the coordinates of these points just below the intersection..is it possible? i searced forum and also other webpages but i couldnt find anything useful..
i hope it is possible and it will be easy for me..

thanks again

CarlB
10th Jun 2005, 10:47 pm
I suggest that the routine calculate all the intersection points, from the original information, rather than use the drawn lines for starting information. The routine already "knows" endpoints of each line; now just step along each line. Something like:

x=x0
Repeat #x
y=y0
Repeat #y
y=y + Dely
coord =x,y
print "x,y" at x,y
End repeat #y
x=x+Delx
End repeat #x

You'll need some offset in x and y for placement of text next to intersecting point, as a function of text height.

nepenthe
11th Jun 2005, 09:23 am
so many thankss..

It helped a lot. but I couldnt add the text..
I tried (command "text"... ). but i dont know the parameters..
and i found an example of (command "dimedit"..). but i dont why it didnt worked.

which one dou you suggest me to use? and if possible could you please give a code..i have to determine x,y of the text and height of the text.

CarlB
11th Jun 2005, 09:17 pm
The parameters for (command "text" ..) should be the same as when you use the TEXT command...insertion point, height, rotation, etc. If the current style has a fixed text height then there is no prompt for text height.

If you have x and y for text insertion, create a point:

(setq TxtPt (list x y))
(command "text" TxtPt TxtHt 0.0 CoordText)

I don't believe you need a return - "" - after the text.