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

create options of choice in lisp

  • Thread starter Thread starter mazzetti68
  • Start date Start date

mazzetti68

Guest
Hello, everyone!

Today I was creating a lisp, which has more functions within it....in the sense that at first I can choose e.g.

choose what to do: [[casa_blu] [casa_rossa] [casa_viola] [casa_gialla]♪

here an example directly from autocad:
esempio.webpIf I choose house_blu does one thing, if I choose house_rossa does another, etc...

I tried with the cond function, but it doesn't work, as I think it only accepts numerical values. . .

I also tried with if, it works....but I can at most give two options of choice.. .

Can anyone give me a tip?

thanks in advance

Good afternoon to all!
 
I forgot to share the example, in case someone does not understand how to apply the magic words of crystal;)
Code:
(initget "casa_blu casa_rossa casa_viola casa_gialla") (setq tipo_casa (getkword "\nselect the type of house: [ casa_blu / casa_rossa / casa_viola / casa_gialla ] : ")
(equal type_house "casa_blu")(alert "blue house"))
(equal type_house "casa_rossa")(alert "red house")
(equal type_house "house_viola")(alert "purple house")
(equal type_house "casa_gialla")(alert "yellow house")
Have a good day!
 
Hello everyone!

I've had a problem with the... It is practically all afternoon that I can't make it work, I've checked everything... but it's not going: the problem is in the written part red, I'm sure, but I don't know how to make it work.

Code:
(defun linea_sx_dx_2 (/)
(setvar "osmode" 0)

(setq margin_2x (- d_bordo-bordo (* margin 2))
(setq p_li_2_sx_1 (list p-base-1-sx (+ p1_y margin_2x) p1_z))
(setq p_li_2_dx_1 (list p-base-1-dx (+ p2_y margin_2x) p2_z))

[COLOR="#FF0000"](initget "sx dx") (setq side_baffetti (getkword "\nindicates the side from the want to insert the baffle: [ SX / DX ]: ")
(cond)
((equal side_baffets "sx")(command "_pline" p-base-1-dx p-base-1-sx p_li_2_sx_1"));;;;;;;;; polyline does not follow the 3rd point....and by error... .
((equal side_baffets "dx")(command "_pline" p-base-1-sx p-base-1-dx p_li_2_dx_1"))
)[/COLOR](setvar "osmode" 16383)
)
should create such a polyline: |______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________This is just an extract, so I only extrapolated the problem... It is worth noting that the points that are not connected to others, in the full lsp are....if someone still needs write that I insert everything!

Does anyone know how to solve the problem, or do you tell me?

I hope you can help me

thank you in advance!!! ...and good afternoon!
 
Hello, everyone!
I have reviewed many times this piece of lsp... everything is correct (except the piece below I believe), but since the problem could come from other points, the whole lsp, I checked and the rest is all correct....so the error is definitely here, in the third point I go to create to have a line to "l" so ________________________________________________________________________________________________________________________________________________________________________________________ I couldn't find anything, and it seems correct. ..however:
Code:
(setq margin_2x (- d_bordo-bordo (* margin 2))
(setq p_li_2_sx_1 (list p-base-1-sx (+ p1_y margin_2x) p1_z)
(setq p_li_2_dx_1 (list p-base-1-dx (+ p2_y margin_2x) p2_z)

(initget "sx dx") (setq side_baffetti (getkword "\nindicates the side from the want to insert the baffle: [ SX / DX ]: ")
(cond)
((equal side_baffets "sx")(command "_pline" p-base-1-dx p-base-1-sx p_li_2_sx_1"));; polylinea does not follow the third point, and error
((equal side_baffets "dx")(command "_pline" p-base-1-sx p-base-1-dx p_li_2_dx_1"));; polyline does not follow the third point, and error
)
I hope someone can help me, maybe in the message before I wasn't very clear. . .
Good evening to all and thank you in advance!
 
First of all thank you for the time you have dedicated me! but unfortunately I have rechecked again line by line, especially parentheses, which is where often errors start. then I looked at the points you said, if there was something wrong, but nothing... It still doesn't work. the code is this:
Code:
(setq p1 (getpoint "\nindicates the starting point of the line: ")
(setq p2 (getpoint "\nindicates the arrival point of the line: ")
(setq margin (getreal "\nindicates margin e.g. 0.2. ")
(setq d_bordo-bordo (getreal "\nindicates the edge-bord distance (e.g. 0.2): ")

(setq p1_x (nth 0 p1))
(setq p1_y (nth 1 p1))
(setq p1_z (nth 2 p1))
(setq p-base-1-sx (list (+ p1_x margin) p1_y p1_z))

(setq p2_x (nth 0 p2))
(setq p2_y (nth 1 p2))
(setq p2_z (nth 2 p2))
(setq p-base-1-dx (list (- p2_x margin) p1_y p2_z))

(defun linea_sx_dx_2 (/)
(Setvar "osmode" 0)

(setq margin_2x (- d_bordo-bordo (* margin 2))
(setq p_li_2_sx_1 (list p-base-1-sx (+ p1_y margin_2x) p1_z)
(setq p_li_2_dx_1 (list p-base-1-dx (+ p2_y margin_2x) p2_z)

(initget "sx dx") (setq side_baffetti (getkword "\nindicates the side from the want to insert the baffle: [ SX / DX ]: ")
(cond)
((equal side_baffets "sx")(command "_pline" p-base-1-dx p-base-1-sx p_li_2_sx_1"))
((equal side_baffets "dx")(command "_pline" p-base-1-sx p-base-1-dx p_li_2_dx_1"))
)

(setvar "osmode" 16383)
)

(initget "1 2") (setq type_linea (getkword "\nselect the line type: [ 1 / 2 ] : ")
(cond)
(equal type_line "1")(initget "1 1baffsin 1baffdest 1baffsind") (setq type_linea_1 (getkword "\nselect the line type: [1 / 1baffsin / 1baffdest / 1baffsind] : )
(cond)
(equal type_linea_1 "1") (alert "to be inserted")
(equal type_linea_1 "1baffsin") (alert "to be inserted")
(equal type_linea_1 "1baffdest") (alert "to be inserted")
(equal type_linea_1 "1baffsind") (alert "to be inserted")
)
(equal type_line "2")(initget "2 2baffsin 2baffdest 2baffsind") (setq type_linea_2 (getkword "\nselect the line type: [2 / 2baffsin / 2baffdest / 2baffsind] : " ))
	(cond 
		[COLOR="#FF0000"](equal type_linea_2 "2") (linea_sx_dx_2 ))[/COLOR](equal type_linea_2 "2baffsin") (alert "to be inserted")
(equal type_linea_2 "2baffdest") (alert "to be inserted")
(equal type_linea_2 "2baffsind") (alert "to be inserted")
)
)
to testare llsp bisogna procedre così:
  • draw a line from left to right.
  • edge -- > 0.25
  • distanzaboard board -- HCFC 0.2
  • valore coprilina -- > 0.65
  • select line 2 type
  • line type 2
  • side baffle sx
Do you know where the mistake is? I can't find anything, these days I'm definitely going crazy to find him:36_1_5::36_1_3:
Thank you in advance and wish you a good evening to all!
 
Look how you built those points, the mistake I think is there.
(setq p_li_2_sx_1) p-base-1-sx (+ p1_y margin_2x) p1_z)
(setq p_li_2_dx_1 (list p-base-1-dx (+ p2_y margin_2x) p2_z)

I'm self-quoted, now that you've posted the code, I have been able to verify that the two highlighted variables are already points, i.e. a set of numbers, as you wrote the code return:

((8.06804 -0.0345874 0.0) -0.234587 0.0)
(26.5849 -0.0345874 0.0) 0.948288 0.0)

so you can't use them as "points" to switch to command.
 
Damn it, you're right! Thank you so much, you're a genius! I know that I will change the names a little so that no more confusion between points and values.... I was confused sx and dx with the subdivision of the point with the abbreviation in x, that I use:(.
Thanks again gp!
Good evening to all! !
 

Forum statistics

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

Members online

No members online now.
Back
Top