Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
kulfi
Posts: 911
Registered: ‎09-29-2005
Message 1 of 13 (288 Views)

DCL Value

288 Views, 12 Replies
02-10-2013 02:12 AM

(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



*Expert Elite*
hmsilva
Posts: 2,841
Registered: ‎12-17-2004
Message 2 of 13 (259 Views)

Re: DCL Value

02-10-2013 02:24 PM 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

 

*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 3 of 13 (254 Views)

Re: DCL Value

02-10-2013 06:48 PM 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

Distinguished Contributor
kulfi
Posts: 911
Registered: ‎09-29-2005
Message 4 of 13 (246 Views)

Re: DCL Value

02-10-2013 10:24 PM 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



*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 5 of 13 (238 Views)

Re: DCL Value

02-10-2013 11:26 PM 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)

....

)

 

 

*Expert Elite*
hmsilva
Posts: 2,841
Registered: ‎12-17-2004
Message 6 of 13 (234 Views)

Re: DCL Value

02-11-2013 01:01 AM in reply to: pbejse

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

 

Cheers
Henrique

*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 7 of 13 (228 Views)

Re: DCL Value

02-11-2013 01:31 AM 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. :smileyhappy:

 

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

 

*Expert Elite*
hmsilva
Posts: 2,841
Registered: ‎12-17-2004
Message 8 of 13 (225 Views)

Re: DCL Value

02-11-2013 01:36 AM 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

*Expert Elite*
scot-65
Posts: 2,175
Registered: ‎12-11-2003
Message 9 of 13 (206 Views)

Re: DCL Value

02-11-2013 04:02 PM 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
Dyslexia is a permanent physical disability that cannot be seen.
Introverts is proof that there is indeed intelligent life on this planet.
*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 10 of 13 (194 Views)

Re: DCL Value

02-11-2013 11:48 PM 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 !!  :smileyvery-happy:

 

 

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

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.