Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DCL Value

12 REPLIES 12
Reply
Message 1 of 13
kulfi
556 Views, 12 Replies

DCL Value

(set_tile "edit1" "Enter Layer Name")
 (set_tile "edit2" "Layer Color")
 (set_tile "edit3" "Distance of Grids")
 (set_tile "edit5" "Text Size")
 (set_tile "edit6" "Cross Size")
 
(action_tile "edit1" "(setq layy $value)")
 (action_tile "edit2" "(setq coll $value)")
 (action_tile "edit3" "(setq elv $value)")
 (action_tile "edit5" "(setq txtsze $value)")
 (action_tile "edit6" "(setq ticsze $value)")

 

when i run the program for the first time i will put the "layer name" "Layer Color" all the parameters i will enter what i want when i have eneterd the parameters once and i run the program they sould appear in the DCL box and i change only the one i need.

Thanks

Kulfi
Electronics Engineer

Pind Saudi Arabia



12 REPLIES 12
Message 2 of 13
hmsilva
in reply to: kulfi

 kulfi,

long time I do not use DCL, but maybe something like this

 

(or layy (setq layy "Enter Layer Name"))
(or coll (setq coll "Layer Color"))

(set_tile "edit1" layy)
(set_tile "edit2" coll)

(action_tile "edit1" "(setq layy $value)")
(action_tile "edit2" "(setq coll $value)")

 

hope that helps

Henrique

 

EESignature

Message 3 of 13
pbejse
in reply to: kulfi


@Kulfi wrote:

 

when i run the program for the first time i will put the "layer name" "Layer Color" all the parameters i will enter what i want when i have eneterd the parameters once and i run the program they sould appear in the DCL box and i change only the one i need.

Thanks


another
(setq InitVal '(("layy" "Enter Layer Name")
                ("coll" "Layer Color")
                ("elv" "Distance of Grids")
                ("txtsze" "Text Size")
                ("ticsze" "Cross Size")))

(foreach Var InitVal
	      (if (setq dflt (eval (read (car var))))
	          	   dflt (set (read (car var)) (cadr var))
      )
	      )

;;;; after DCL_load ;;;; (set_tile "edit1" layy) (set_tile "edit2" coll) (set_tile "edit3" elv) (set_tile "edit5" txtsze) (set_tile "edit6" ticsze) (action_tile "edit1" "(setq layy $value)") (action_tile "edit2" "(setq coll $value)") (action_tile "edit3" "(setq elv $value)") (action_tile "edit5" "(setq txtsze $value)") (action_tile "edit6" "(setq ticsze $value)")

 

HTH

Message 4 of 13
kulfi
in reply to: pbejse

Below is how i have arrange in my Program but when i run the program second time all the boxes are empty

this is not what i need

i need whatever the values i enterd the first time they should appear in the boxes.

thanks

 

(if (not (new_dialog "laygrid" dcl_id))(exit))

 

(setq InitVal '(("layy" "Enter Layer Name") ("coll" "Layer Color") ("elv" "Distance of Grids") ("txtsze" "Text Size")                 ("ticsze" "Cross Size")))

 

(foreach Var InitVal (if (setq dflt (eval (read (car var)))) dflt (set (read (car var)) (cadr var))))

 

(start_dialog) ;;;;  after DCL_load   ;;;;

(set_tile "edit1" layy)

(set_tile "edit2" coll)

(set_tile "edit3" elv)

(set_tile "edit5" txtsze)

(set_tile "edit6" ticsze)

(action_tile "edit1" "(setq layy $value)")

(action_tile "edit2" "(setq coll $value)")

(action_tile "edit3" "(setq elv $value)")

(action_tile "edit5" "(setq txtsze $value)")

(action_tile "edit6" "(setq ticsze $value)")   

(unload_dialog dcl_id)

Kulfi
Electronics Engineer

Pind Saudi Arabia



Message 5 of 13
pbejse
in reply to: kulfi


@Kulfi wrote:

Below is how i have arrange in my Program but when i run the program second time all the boxes are empty

this is not what i need

i need whatever the values i enterd the first time they should appear in the boxes.

thanks

 

(if (not (new_dialog "laygrid" dcl_id))(exit))

 

(setq InitVal '(("layy" "Enter Layer Name") ("coll" "Layer Color") ("elv" "Distance of Grids") ("txtsze" "Text Size")                 ("ticsze" "Cross Size")))

 

(foreach Var InitVal (if (setq dflt (eval (read (car var)))) dflt (set (read (car var)) (cadr var))))

 

(start_dialog) ;;;;  after DCL_load   ;;;;

(set_tile "edit1" layy)

(set_tile "edit2" coll)

(set_tile "edit3" elv)

(set_tile "edit5" txtsze)

(set_tile "edit6" ticsze)

(action_tile "edit1" "(setq layy $value)")

(action_tile "edit2" "(setq coll $value)")

(action_tile "edit3" "(setq elv $value)")

(action_tile "edit5" "(setq txtsze $value)")

(action_tile "edit6" "(setq ticsze $value)")   

(unload_dialog dcl_id)


 

This lines should run before DCL loading

 

(setq InitVal '(("layy" "Enter Layer Name") ("coll" "Layer Color") ("elv" "Distance of Grids") ("txtsze" "Text Size")                 ("ticsze" "Cross Size")))

 

(foreach Var InitVal (if (setq dflt (eval (read (car var)))) dflt (set (read (car var)) (cadr var))))

 

(if (not (new_dialog "laygrid" dcl_id))(exit))

(set_tile "edit1" layy)

(set_tile "edit2" coll)

(set_tile "edit3" elv)

......

 

and you probably declared variables layy/coll/elv/txtsze/ticsize as local, should be global

 

(Defun c:commandname (/  variables above should not be here)

....

)

 

 

Message 6 of 13
hmsilva
in reply to: pbejse

pbejse,
just one question, my method would work if define these variables as global variables?

 

Cheers
Henrique

EESignature

Message 7 of 13
pbejse
in reply to: hmsilva


@hmsilva wrote:

pbejse,
just one question, my method would work if define these variables as global variables?

 

Cheers
Henrique


Of course It will work Henrique, i just suggested an alternative kind sir. 🙂

 

<quote from my first post >
another 
(setq InitVal '(("layy" "Enter Layer Name").....
Cheers Henrique

 

Message 8 of 13
hmsilva
in reply to: pbejse

pbejse,
thanks for your reply, is that I dont use DCL for a long time and I was not sure...

 

Cheers
Henrique

EESignature

Message 9 of 13
scot-65
in reply to: kulfi


@Kulfi wrote:

(set_tile "edit1" "Enter Layer Name")
 (set_tile "edit2" "Layer Color")
 (set_tile "edit3" "Distance of Grids")
 (set_tile "edit5" "Text Size")
 (set_tile "edit6" "Cross Size")
 
(action_tile "edit1" "(setq layy $value)")
 (action_tile "edit2" "(setq coll $value)")
 (action_tile "edit3" "(setq elv $value)")
 (action_tile "edit5" "(setq txtsze $value)")
 (action_tile "edit6" "(setq ticsze $value)")

 

when i run the program for the first time i will put the "layer name" "Layer Color" all the parameters i will enter what i want when i have eneterd the parameters once and i run the program they sould appear in the DCL box and i change only the one i need.

Thanks


Still yet is another method that should be more easy to understand (and structurally more correct):

 

;Declare a function [USERSETUP is the gremlin here]:

(defun USERSETUP_GET ()

 (setq USERSETUP (list

  (get_tile "edit1")

  (get_tile "edit2")

  (get_tile "edit3") ;etc.

 ))

);defun

 

;Initialize your settings:

(if (not USERSETUP)

 (setq USERSETUP (list

  "Name"

  "Color"

  "Grid" ;etc.

 ))

);if

 

;<--load the dcl here-->

(set_tile "edit1" (nth 0 USERSETUP))

(set_tile "edit2" (nth 1 USERSETUP))

(set_tile "edit3" (nth 2 USERSETUP))

(action_tile "accept" "(USERSETUP_GET)(done_dialog 1)")

(setq sd (start_dialog))

;<-- unload here-->

 

;To process your values [done_dialog returns a value to start_dialog]:

(if (and sd (= sd 1))

 [your main program here]

);if

 

(setq sd nil)

 

 

Hope this helps.

 

Do a keyword search of my handle and you will find other DCL examples I have provided that are very similar with this type of structure.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 10 of 13
pbejse
in reply to: scot-65


@scot-65 wrote:

Still yet is another method that should be more easy to understand (and structurally more correct):

 

 

 


Ouch !!  😄

 

 

For kulfi, 

 

The snippet below will convert the variable values back into a string , get_tile function return values is a "string" now depending on the main program where you do the conversion from string to a valid value [elv/coll/txtsize/ticsize] and you ended up with a none string value.

 

 

(foreach Var '(("layy" "Enter Layer Name")
                ("coll" "Layer Color")
                ("elv" "Distance of Grids")
                ("txtsze" "Text Size")
                ("ticsze" "Cross Size"))
  	      (set_tile (car var)
                  (set (read (car var)) 
                    (if (setq dflt (eval (read (car var))))
                        (cond
                              ((eq (setq ty (type dflt)) 'STR) dflt)
                  	      ((eq ty 'REAL) (rtos dflt 2 2))
                  	      ((eq ty 'INT) (itoa dflt)))
	          	   (cadr var)))
	      )
      )

 

Now this would be inside load/unload dialog 

 

HTH

 

Message 11 of 13
scot-65
in reply to: pbejse

There was a start dialog declaration in one of the responses that was in the wrong place.

...that's why the comment.

🙂

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 12 of 13
kulfi
in reply to: kulfi

Hi, thanks to every one helping me but the problem here when I enter all the values first time and come back the second time , all the dcl boxes are empty even I declare all the variables globally because I am using these variables in rest of the program. Thanks
Kulfi
Electronics Engineer

Pind Saudi Arabia



Message 13 of 13
pbejse
in reply to: kulfi


@Kulfi wrote:
Hi, thanks to every one helping me but the problem here when I enter all the values first time and come back the second time , all the dcl boxes are empty even I declare all the variables globally because I am using these variables in rest of the program. Thanks

kulfi, you may have a better chance of understanding the code posted by scot-65,

 

The last code i posted combines assigning the default and passing the value to set_tile all at one go. only thing you need to change are the tile key names on your DCL and lisp code

 

"edit1 to "layy"

"edit2" to "coll"

"edit3" to "elv"

"edit5" to "txtsze"

"edit6" to "ticsze"

 

Otherwise . post you code here to give us a beter picture on why its not working for you

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost