Help: Example for rectangle parametric

Started by mclisp, July 06, 2012, 06:51:16 AM

Previous topic - Next topic

mclisp

Hello

Iapologize for my bad English.
I'm studying OpenDCL, the documentation is very extensive, and I do not understand.

I wish someone could post a small sample application to parametrize a rectangle composed of four lines,

You should ask the insertion point, the angle to draw, you open the form Modeless, (see examples modeless.lsp)

the form may contain No. 2 textbox with the measurement of the two sides and a combobox with the type of continuous,

hidden, line ... etc..

modifying the dimension of a side, dynamically should delete the preceding rectangle and create the new rectangle.
I hope not too much to ask, I thank those who will take time for me
thanks
mclisp

owenwengerd

Owen Wengerd (Outside The Box) / ManuSoft

mclisp

#2
Hello and thanks for your time, here is part of my test, I attach the files

1)One form MODELESS (which remains open) with two textboxes, one combobox and a button closure. IS OK
2)loading the lisp file, first open the form, asks the insertion point and angle for the rectangle shape. IS OK
3)before opening the form, set the value of the textbox in the two sides of the rectangle, say 800 and 400
 also sets the combobox with the list of types of lines "continuous, hidden" etc. IS OK
4)open the form and draw the rectangle. IS OK

from here I do not understand how to make

5)if I change a measure in one of the two textbox, the program would draw a new rectangle with the new values
   i tried with the edit change event but it doesn't work.

any help is appreciated
Thanks

hmspe

You might want to look specifically at the modeless.lsp and modeless.odcl files in the OpenDCL samples. 

A starting point:  modeless form controls are normally ASYNCHRONOUS, not SYNCHRONOUS.

owenwengerd

I did not look at your code, but EditChanged should work. What did not work when you tried it?
Owen Wengerd (Outside The Box) / ManuSoft

hmspe

I put together a quick example based on your request.  This is prototype code that has not been cleaned up and fully tested.  I look at this as a learning exercise, not necessarily as a function to use when creating drawings.  I tried to match the functions in the original rectangle.lsp rather than write a complete routine that does everything listed in the original post. 

There are several things incomplete with this function:
1.  The rectangle is drawn as line segments.  This will make updating the linetype more difficult since each line segment will have to be handled separately.  Unless there is a reason to have line segments a lwpolyline would be a better choice.  I would suggest using entmake instead of the line command or pline command.  An example is in post #2 at http://www.cadtutor.net/forum/showthread.php?51210-Creating-Rectangles
2.  There is a drop-down box in the ODCL form for linetype but the code in the original rectangle.lsp does not do anything with it.  The drop-down box should be initialized with the linetype of the first rectangle.  I would use ENTMOD to update the rectangle's linetype.
3.  The original rectangle is not deleted in the original rectangle.lsp so I did not add code to delete the original rectangle.   

mclisp

I really thank everyone for their availability, especially HMSPE for his example.
I confirm that this is supposed to be only a year of study.
My file type is already RECTANGLE.ODCL MODELESS and I started studying precisely the file MODELESS.odcl examples.
For now I do not care if the rectangle does not clear, I want to study OpenDCL I repeat this is only a test.
I want to change a dimension, it must redraw the rectangle.

owenwengerd, I tried EditChange I think is correct.
if I write:
(defun c:Rectangle_Form1_TextBox1_OnEditChanged (NewValue / )
         (drawrectangle)
)

;;DrawRectangle
(defun DrawRectangle ( / side1 side2 p1 p2 p3 p4 )
(setq side1 (atof (dcl_Control_GetText Rectangle_Form1_TextBox1)))
(setq side2 (atof (dcl_Control_GetText Rectangle_Form1_TextBox2)))
(setq p1 ptStart
      p2 (polar p1 ang side1)
      p3 (polar p2 (+ ang (/ pi 2)) side2)
      p4 (polar p3 (+ ang pi) side1))
(command "_line" p1 p2 p3 p4 p1 "")
);defun DrawRectangle


the function DrawRectangle expected read the new values ​​in textbox1 and redraw the rectangle,
but this does not happen, when I write each number in textbox1 returns me ERROR:
Application Error: 2 :- invalid AutoCAD command: nil
Application Error: 2 :- invalid AutoCAD command: nil
Application Error: 2 :- invalid AutoCAD command: nil
Thanks




owenwengerd

In order to use (command) inside your event handler, you must set the control's Event Invoke property to 1 - Asynchronous.
Owen Wengerd (Outside The Box) / ManuSoft

mclisp

Quote from: hmspe on July 08, 2012, 07:16:26 AM
You might want to look specifically at the modeless.lsp and modeless.odcl files in the OpenDCL samples. 

A starting point:  modeless form controls are normally ASYNCHRONOUS, not SYNCHRONOUS.

ok with ASYNCHRONOUS selecting the concept is OK

(defun c:Rectangle_Form1_TextBox1_OnEditChanged (NewValue / )
   (drawrectangle)(princ)
)

but now, if I want to write and let texbox1 181 in 400 in texbox2
are drawn three rectangles
one with dimensions 1x400
another with dimensions 18x400
and the third with dimensions 181x400
how can
I tell when the user has entered all of the string, to work function (DrawRectangle) once.
Thanks



owenwengerd

That is a design decision you'll have to make. The OpenDCL Studio property window applies changes when the user presses <Enter> and when the control loses focus, so that might work in this case as well.
Owen Wengerd (Outside The Box) / ManuSoft

mclisp

 Thanks owenwengerd for your information.
(killfocus) works well, now it seems easy OpenDCL.

Code (autolisp) Select
(defun c:Rectangle_Form1_TextBox2_OnKillFocus ( /)
   (drawrectangle)(princ ));defun


Thanks for your work,
with the lisp, now I will open new horizons.
I would like your comments or additions
ciao