• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

lisp and dcl to create automatic fixtures

  • Thread starter Thread starter marcmemba
  • Start date Start date

marcmemba

Guest
hello to all is for a while that I haven't been through the parts of this beautiful forum, congratulations to all that is always full of people really good, you always find very interesting things:smile: Congratulations! But unfortunately I have not found a forum where we talk about dcl:(, and I hope someone can help me. I'll be out in a moment. .
I've just been practicing in dcl, but I can't. I found several guides in English, but I can't understand them. The only thing I could do is read "this is a message." . .
I wanted to create a window where you can enter the data in a "edit_box":

-number of windows:
- Parapet rate:
-quota architrave:
- horizontal opening:

I then go to resume the data "key" from the dcl with the lisp, so I go to create a tabellina with lines and polylines. but this is already the final result I would like to have, but first I will have to understand how to resume the data; then:
Like something like this:
Code:
(defun no_finestra "key_parapetto")
(defunct q_parapetto "key_window")
(defun q_architrave "key_architrave")
(defun a_orizzonatle "key_orizzonatle")
(command "_text" (command "_text" "_br" pauses "1.5" "0" no_window))
(command "_text" (command "_text" "_br" pauses "1.5" "0" q_parapetto))
(command "_text" (command "_text" "_br" pauses "1.5" "0" q_architrave))
(command "_text" (command "_text" "_br" pauses "1.5" "0" a_orizzonatle))
it is to specify that I realize that you can do quietly in lsp, but to start I think simple things go well....)

Could someone and above all would have time to help me?

Thank you in advance and wish you a good evening to all! !

This is the window I wanted to create in dcl.... :Cattura.webp
 
...
I've just been practicing in dcl, but I can't. I found several guides in English, but I can't understand them. The only thing I could do is read "this is a message." . .
I wanted to create a window where you can enter the data in a "edit_box":
-number of windows:
- Parapet rate:
-quota architrave:
- horizontal opening:
...View attachment 40521
Bye-bye marcmemba
I'm not expert in dcl, but a simple one like what you asked, I think I know how to do it. I tried and it works. Don't ask me what I wrote because I don't know. satisfied that it works. there are 2 files:
the inputbox4.dcl file:

inputbox4: dialogue {
label="program windows";
spacer_1;
: edit_box {
label = "fine number";
height = 1;
is_bold = true;
key = "nf1";
edit_width =40;
edit_limit = 256;
allow_accept = true;
?
: edit_box {
label = "parapett quota";
is_bold = true;
key = "qp1";
edit_width =40;
edit_limit = 256;
allow_accept = true;
?
: edit_box {
label = "architrave quota";
is_bold = true;
key = "qa1";
edit_width =40;
edit_limit = 256;
allow_accept = true;
?
: edit_box {
label = "horizontal opening";
is_bold = true;
key = "ao1";
edit_width =40;
edit_limit = 256;
allow_accept = true;
?
spacer_1;
ok_cancel;
?

and the file pfinestra.lsp

; French programme.lsp
;autocad 2014 28-04-2015

(setq dcl_id (load_dialog "inputbox4.dcl"))
(if (new_dialog "inputbox4" dcl_id))(exit))
(if (equal (type nf) 'real)(setq nf(rtos nf))))
(if (not nf); imposed in the dcl the value of the window number
(set_tile "nf1" (setq nf "1"))
(set_tile "nf1" nf)
)
(if (equal (type qp) 'real)(setq qp(rtos qp)))
(if (not qp); imposed in the dcl the value of the parapett quota
(set_tile "qp1" (setq qp "1.25"))
(set_tile "qp1" qp)
)
(if (equal (type qa) 'real)(setq qa(rtos qa)))
(if (not qa); imposed in the dcl the value of the architrave quota
(set_tile "qa1" (setq qa "1.85"))
(set_tile "qa1" qa)
)
(if (equal (type ao) 'real)(setq ao(rtos ao))))
(if (not ao); imposed in the dcl the horizontal opening value
(set_tile "ao1" (setq ao "110.00"))
(set_tile "ao1" ao)
)
(action_tile "nf1"(setq nf $value)");; recovery of the number window
(action_tile "qp1" (setq qp $value));;; recovery the value of the parapett quota
(action_tile "qa1" (setq qa $value));;; recovery of the value of the architrave quota
(action_tile "ao1" (setq ao $value));;; recovery the horizontal opening value
(action_tile "accept" (done_dialog 1))
(setq answer (start_dialog))
(unload_dialog dcl_id)
(if)
(progn)
(setq p1 (getpoint "\nimmetti punto scritto "); first written point
text (strcat " window nf " - quota parap. " qp " - arch share. " qa " - opening " ao);; text
)
(command "_text" p1 "" 0 text);; testo
)
)
(princ)

to try it: (command "pfinestra")
should start the box from which back the variables you ask.
in the program I do only a writing, you can take it from there with the available variables.
Hi.
 
Thank you very much! It works perfectly :) is exactly what I needed! now I am much more clear than how they use:finger: then to build the table I thought to create different texts and refer them all to coordinates linked to p1 (only placed on the axis y).

I have only one question...I wanted to extract the value of the window height automatically, so doing qa-qp (the quota architrave less parapet quota), only a volt written the function (setq hf (- qa qp)), it gives me error: error: type of wrong topic: numberp: "1.85"
Code:
.
.
.
.
(unload_dialog dcl_id)
(if)
(progn)
[COLOR="#FF0000"](qq hf (- qp)[/COLOR]p1 (getpoint "\nimmetti point written ");; first written point
text (strcat " window nf " - quota parap. " qp " - arch share. " qa " - opening " ao [COLOR="#FF0000"]"- height window " hf[/COLOR]);;; testo
)

(command "_text" "ms" p1 "" 0 testo);;; scrive testo 
)
) 
(princ)
Does anyone know what is due and if you can perform mathematical operations? is it due to the fact that it is not in the form of value the number 1.85 extracted from the dcl?

thanks in advance and good afternoon
 
la dcl recepisce e re-establishment a string, if you want to use it as a real number you have to use atof:


(setq a "1.85")
"1.85"
_$

(atof a)
1.85
_$
 
Thank you very much!! Now it works great!:smile:
a last thing I wanted to ask....I put a text box where to insert the values 1 and 2, if I insert 1 I can insert the data for a door, instead if I insert 2 I can insert the data for the window.
This I think is a passage not very convenient....I saw that there are radiobuttons, that would do this, I have inserted them and up here everything ok, then to the first I gave value="1"; and to the second value="0"; But then I would like to connect it to the lisp... which I searched on the internet for examples but failed, and I think I would also need the function (mode_tile key mode) to disable the unselected part. Does anyone have an example?
thank you in advance and good evening to all!
 
thanks gp the second I had already read it but the first only in part.
Now I've refurbished them and tried to put them into practice but I still can't understand how to use them....because I can't figure out how the "null value" is handled (the one not selected), ...and I don't know how to extract the data....http://web2.airmail.net/terrycad/tutorials/mydialogs.htm#myradios here I didn't find it or though maybe I couldn't "decipher it" correctly. . .
someone does not have an example like what put beton, where for example I can choose blue window or green window (in radio_button) and then I get inserted text in autocad with the written blue or green window? for me it is much easier to understand from an example applied to something simple..., I saw that these dcls are written very differently from how I do them at my level. . .
Thank you in advance and I hope someone can help me and wish everyone a good afternoon! !
 
I wanted to be too far ahead of my poor level...
I am now reading various forums in English with google translator, but coming to the crucial point that I need they impappino :(.....I wanted to ask you kindly if someone knows how to explain to me what these (red), that I have never met them in lsp, type backslash, the function within quotes, etc... :
Code:
; rb is for stands radio button

(defun c:rb (/ dcl_id ans)
  (setq dcl_id (load_dialog "radio button.dcl"))
  (if
    (not (new_dialog "rb" dcl_id))
    (exit)
    )
  (set_tile "rb1" "1")
  (mode_tile "rb1" 2)
  (mode_tile "rb2" 2)
  (mode_tile "rb2" 2)
  (action_tile "rb1" "(setq data_rb1 (get_tile \"rb1\"))")                             
  (action_tile "rb2" "(setq data_rb1 (get_tile \"rb1\"))")                             
  (action_tile "rb3" "(setq data_rb1 [COLOR="#FF0000"](get_tile \"rb1\")") [/COLOR] (actions _ tile "accept" "(done _ dialogue 1)")
(setq ans (start _ dialogue))
(prince)
)
he uses the dcl.
Code:
rb : dialog {label= "radio button manager";
   : row {label = "choose a radio button";
   : radio_button {label= "radio button 1";
                   key= "rb1";}
   : radio_button {label= "radio button 2";
                   key= "rb2";}
   : radio_button {label= "radio button 3";
                   key= "rb3";}}         
   ok_only;}
Thank you in advance whoever can help me, good evening to all!
 
Okay, maybe I was asking too much... .
No, we've done a lot more... the problem, for my part, is that for two weeks I have worked 14 hours a day (including Saturday and Sunday morning).
:36_1_5:

That said...
(setq data_rb1 (get_tile \"rb1\"))...when selecting the box "rb1" checks to the variable data_rb1 the value of the box, or una stringa of text, which to be such must be enclosed between quotes.

since the "virgolette" in autolisp are a control character, in order to be able to view them (e.g. in the command line or in a dialog box), you must prioritize the backslash character (downside bar).
 
Some gp is a huge help what you gave me to start. . .I am really grateful for your help and the fear you have spent for me! This week I drowned forums and guides for dcl, and I would say that it has yielded a lot :) I would also say that I managed to make some progress :smile::smile:
Look:Programma_porte_fiestre_dcl.webpin flood file lisp and dcl
Code:
.
.
.[COLOR="#FF0000"];;;;; popup list
(setq lista-elenco-popup (list "10" "250")

(start _ list "popup _ list1" 3)
(mapcar 'add _ list lista-elenco-popup)
(end _ list)
(action _ tile "popup _ list1" "(setq popup _ list $value)")[/COLOR].
.
.
;;text x data
(setq p1 (getpoint "\nimmetti punto finestra")
text (strcat "number window:" nf " // parapet quota window:" qpf " // quote architrave window:" qaf " // window opening:" aof)

text1 (strcat "number of doors:" np " // quota architrave door:" qap " // horizontal opening door:" aop)

 [COLOR="#FF0000"]text2 (strcat "color: "popup_list"[/COLOR]
)
.
.
.[COLOR="#FF0000"](setq p3 (getpoint "\nimmetti punto colore")
(command "_text" p3" 0 text2)[/COLOR])
)
(prince)
dcl:
Code:
[COLOR="#FF0000"]: popup_list {
                key = "popup_lista1";
                label = "colore testo (10=rosso; 250=nero)";
                width = 30;
                value = "";
              }[/COLOR]
But then I got a probe with the popup_list, that is, I can't extract the data that I chose from the list... I couldn't understand if you have to assign values to the data of the list es:
10 --> 1 and 250 --> 2 (in the text I go to write I always return 1:confused:)
or extract the chosen value es: if I choose 10 I get the value 10 and if I choose 250 I get the value 250, you know how to help me? (I colored in red the part of popup in the code lisp and dcl above)
(if it is useful I looked which: http://www.jefferypsanders.com/autolisp_dcl_part4.htmlBut I didn't understand how to extract data... )
Thank you again and wish you a great day to all! !
 

Attachments

Actually, the value returned by the popup_list variable is nothing but a string format number that represents the value position you have chosen in the popup list. to get the desired value you have to operate like this:

(setq value_desirable (nth (popup_list) list-popup))

Note that the string value of the popup_list variable must be converted into full number with the atoi function.
as further advantage you may enter a default value, so that the value is selected automatically without intervening in the popup_list.
 
Thank you very much confutatis,
I tried to apply this method but it always gives me as a result 250, except if I choose 250 comes out 250, but if I choose 10 it also comes out 250.. .
here the modified code (red):
Code:
.
.
.
(if)
(progn)
[COLOR="#FF0000"](setq number_color(nth) list-popup list-)[/COLOR])
;;text x data
(setq p1 (getpoint "\nimmetti punto finestra")
text (strcat "number window:" nf " // parapet quota window:" qpf " // quote architrave window:" qaf " // window opening:" aof)

text1 (strcat "number of doors:" np " // quota architrave door:" qap " // horizontal opening door:" aop)


)
(command "_text" "ms" p1 "" 0 text)

(setq p2 (getpoint "\nimmetti punto scritto porta"))
(command "_text" p2" 0 text1)

(setq p3 (getpoint "\nimmetti punto colore")
(command "_text" p3 ") 0 [COLOR="#FF0000"]number_color[/COLOR])
)
)
(prince)
I don't think I've done anything wrong... but it doesn't go...

for the arrangement you suggested to me (default value), I tried with value=1; in dcl but it doesn't go, that I probably think that in popup_list you don't accept it...you know what should be inserted?

Thank you in advance and wish you a good evening to all! !
 
This is the complete list, but it worked quietly, I don't know what to say...
Code:
;program_porte_finestre.lsp
(defun c:porfin ()
(setq dcl_id (load_dialog "inputbox_porte_finestre.dcl"))
(if (new_dialog "prog_pf" dcl_id))(exit))

;; position number window
(if (equal (type nf) 'real)(setq nf(rtos nf))))
(if (not nf)
(set_tile "nf1" (setq nf "1"))
(set_tile "nf1" nf)
)

;; window parapet quota
(if (equal (type qpf) 'real)(setq qpf(rtos qpf)))
(if (not qpf)
(set_tile "qpf1" (setq qpf "+1.85"))
(set_tile "qpf1" qpf)
)

;; architrave window quota
(if (equal (type qaf) 'real)(setq qaf(rtos qaf)))
(if (not qaf)
(set_tile "qaf1" (setq qaf "+2.45"))
(set_tile "qaf1" qaf)
)

;; horizontal opening window
(if (equal (type aof) 'real)(setq aof(rtos aof)))
(if (not aof)
(set_tile "aof1" (setq aof "0.9"))
(set_tile "aof1" aof)
)

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

;; port position number
(if (equal (type np) 'real)(setq np(rtos np)))
(if (not np)
(set_tile "np1" (setq np "1"))
(set_tile "np1" np)
)

;;
(if (equal (type qap) 'real)(setq qap(rtos qap)))
(if (not qap)
(set_tile "qap1" (setq qap "+2.80"))
(set_tile "qap1" qap)
)

;; horizontal door opening
(if (equal (type aop) 'real)(setq aop(rtos aop))))
(if (not aop)
(set_tile "aop1" (setq aop "1.2")
(set_tile "aop1" aop)
)

(if popup_list)
(set_tile "popup_lista1" popup_lista)
(set_tile "popup_lista1" (setq popup_list "0"))
)

;; window
(action_tile "nf1" (setq nf $value))
(action_tile "qpf1" (setq qpf $value)")
(action_tile "qaf1" (setq qaf $value))
(action_tile "aof1" (setq aof $value))
;; door
(action_tile "np1" (setq np $value))
(action_tile "qap1" (setq qap $value))
(action_tile "aop1" (setq aop $value))
;; popup list
(setq list-popup list(list "10" "250"))
(start_list "popup_lista1" 3)
(mapcar 'add_list-list-popup)
(end_list)
(action_tile "popup_lista1" (setq popup_lista $value)")
; radio_button
(action_tile "finstra_radio1" (setq finstra_radio \"finstra_radio1\") (mode_tile \"np1\" 1)(mode_tile \"qap1\" 1)(mode_tile \"aop1\"1)(mode_tile \"nf1\" 0)(mode_tile \"qaf1\"
(action_tile "port_radio1" (setq porta_radio \"port_radio1\") (mode_tile \"nf1\" 1)(mode_tile \"qaf1\" 1)(mode_tile \"aof1\")(mode_tile \"qpf1\"1)(mode_tile \"np1\" 0)(mode_de_style
(action_tile "accept" (done_dialog 1))
(setq answer (start_dialog))
(unload_dialog dcl_id)
(if)
(progn)
(setq number_color(nth) list-popup))
;;text x data
(setq p1 (getpoint "\nimmetti punto finestra")
text (strcat "number window:" nf " // parapet quota window:" qpf " // quote architrave window:" qaf " // window opening:" aof)
text1 (strcat "number of doors:" np " // quota architrave door:" qap " // horizontal opening door:" aop)
)
(command "_text" "ms" p1 "" 0 text)
(setq p2 (getpoint "\nimmetti punto scritto porta"))
(command "_text" p2" 0 text1)
(setq p3 (getpoint "\nimmetti punto colore")
(command "_text" p3 "" 0 number_color)
)
)
(princ)
)
on the dcl I deleted the value line = 1 because there is already the management of the initial value in the lisp, besides it has the great advantage that always stores the last selection:

(if popup_list)
(set_tile "popup_lista1" popup_lista)
(set_tile "popup_lista1" (setq popup_list "0"))
)

if popup_list exists, the tile is set, otherwise the first value of the list is set, i.e. 10 (attention that always starts from "0")
 
Thank you so much!!
now I have replaced with your lisp and it works as I dreamed :smile:, I don't know where the problem was...:confused:.now I will look behind:finger:
very interesting the explanation of the default value, that otherwise only so to code I would have understood it barely :rolleyes: I will also try radiobutton at the beginning:)
thanks endless and good evening to all!! !
 
Hi, I read with interest all the discussion and I wanted to try to use this lisp but I just can't.
I did as for the other lisp:
1- apro appload
2- load the file lsp
3- I use the relative command "portfin"

Is there any passage to do that I'm not aware of?

Thank you.
 
have you copied the .dcl file in a folder inserted in the search paths of autocad or in the folder where autocad resides?
 
I put the .dcl file in
c:\program files\autodesk\autocad 2016\support

Do I have to upload it somehow in autocad or just upload the .lsp file from appload? if you in what way?
 
I put the .dcl file in
c:\program files\autodesk\autocad 2016\support

Do I have to upload it somehow in autocad or just upload the .lsp file from appload? if you in what way?
you need to load the .lsp with appload
 
the .lsp file I uploaded it with appload, but the following error comes out when I try to start the command:
command: porfin
; error: exit / continue

Is the .dcl fiole okay put in this folder?
c:\program files\autodesk\autocad 2016\support
and just put it in a folder of the autocad path or you must also load somehow like the lsp file?
 
the .lsp file I uploaded it with appload, but the following error comes out when I try to start the command:
command: porfin
; error: exit / continue

Is the .dcl fiole okay put in this folder?
c:\program files\autodesk\autocad 2016\support
and just put it in a folder of the autocad path or you must also load somehow like the lsp file?
I think so, if you launch the options command in the file table the first item of the tree lists the search paths and there must be yours as well.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top