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

What's wrong with this DCL, please!?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
jotaferrer
408 Views, 7 Replies

What's wrong with this DCL, please!?

Hello everyone,

 

I've been coding my very first DCL after a journey on learning autolisp and I'm facing a wall over here...

 

I want to create some conditions that will disable a title. The way I made doesn't do the job because when I change the first action_title option, it doesn't refresh or changes the mode_title as it should be.

 

For example, when the user select ANGLE EQ LEG in the first action_title it should unable the Misc. radio_button. But if after clicking ANGLE EQ LEG, the user selects ROUND BAR the Misc. radio_button should be enabled again.

 

PS: The filter I've tried to make can be found between lines #33 and #37

 

Can anyone help me through this, please? Thanks in advance!

 

 

(defun c:somefunc ()
  (setq p_id nil p_desc nil prodsel nil prodsel2 nil selected nil)
  (drivein)
  (setq dcl_id (load_dialog "PATH"));personal info
  (if (not (new_dialog "jf_catalog" dcl_id)) (exit)) ; if the dcl isn't found, it won't let CAD break


;;PRODUCT
  (setq file_name (strcat drive_in "path")) ;personal info
  (read_file)
  (setq lbox_list_type (start_list "ss_prod"))
  (mapcar 'add_list a_list)
  (end_list)
  (action_tile "ss_prod" "(prodlist)")  
  

;;MATERIAL
  (action_tile "box_mat" "(prodmat)")

  
;;OK_CANCEL
  (action_tile "cancel" "(done_dialog 0)")
  (action_tile "accept" "(done_dialog 1)")
  
  
;;LAST STEP  
  (setq box_dialog (start_dialog)) 
  (unload_dialog dcl_id) 
  (princ)
)

(defun prodlist ()
  (setq prodsel $value)
  (if (or (= prodsel "1")(= prodsel "2")
        )
        (mode_tile "1" 1) ;0 = enabled | 1 = unabled
  );FILTER
  (if
    (or
      (= prodsel "0")(= prodsel "12")(= prodsel "18")(= prodsel "19")
    );EMPTY LISTS
    (progn
      (setq file_name (strcat drive_in "path"));personal info
      (read_file)
      (start_list "prod_list")
      (mapcar 'add_list a_list)
      (end_list)
    );opens a standard message
    (progn
      (setq file_name (strcat drive_in "path" prodsel "0.txt")) ;personal info
      (read_file)
      (start_list "prod_list")
      (mapcar 'add_list a_list)
      (end_list)
      (action_tile "prod_list" "(setq selected $value)")
    )
  )
)

(defun prodmat ()
  (setq prodsel2 $value)
  (setq file_name (strcat drive_in "path" prodsel prodsel2 ".txt")); personal info
  (read_file)
  (start_list "prod_list")
  (mapcar 'add_list a_list)
  (end_list)
)

(defun read_file (/)
  (setq a_list nil)
  (setq dsg_file file_name)
  (setq open_file (open dsg_file "r"))
  (while (setq r_line (read-line open_file))
    (setq a_list (cons r_line a_list))
  )
  (setq a_list (reverse a_list))
  (close open_file)
)

 

 

 

 

 

 

Tags (1)
Labels (1)
  • DCL
7 REPLIES 7
Message 2 of 8
andkal
in reply to: jotaferrer

Hello
The third paragraph you wrote is a little bit confusing.
If the user clicks "ANGLE EQ LEG" ( I guess here it is a button?)  it should disable the tile "Misc" but if he clicks the same "ANGLE EQ LEG"  it should enable the tile "Misc"? It makes no sens.

 

But as you have yourself wrote in your code mode_tile is responsible for enabling / disabling the tile. So try something like:

(action_tile "ANGLE EQ LEG" "(mode_tile \"4\" 1) ");disable tile Misc.
Change only >ANGLE EQ LEG< for the key you use for that button. Or if you want to enable the tile:
(action_tile "ANGLE EQ LEG" "(mode_tile \"4\" 0) ");enable tile Misc.

Other example: - if you want to enable one tile and disable another one:
(action_tile "ANGLE EQ LEG" "(mode_tile \"4\" 1) (mode_tile \"3\" 0)")

If it is a checkbox and you want to use it to enable / disable another tile depending on if it is checked or not then try:
(action_tile "ANGLE EQ LEG" "(mode_tile \"4\" (- 1 (atoi $value))) " )


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
Message 3 of 8
andkal
in reply to: jotaferrer

(reply edited)


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
Message 4 of 8
jotaferrer
in reply to: andkal

@andkal thanks for answering! Sorry if I didn't make it clear, english isn't my first language.

The "ANGLE EQUAL LEG" belongs to a list_box and the Misc. belongs to a radio_button

 

I'm try to figure out how apply what you said but I'm afraid I can't.

 

For example:

If the user selects, in the list_box "FLAT BAR", then Misc. will enable

BUT

After clicking it, the user clicks "ANGLE EQ LEG", then Misc. should be disabled;

BUT (hehe)

If he clicks a product that has something in Misc. it should be enabled again... I think you got the point

 

My code as it is, just work at the first click, so, if the user clicks "ANGLE", no matter if he chooses another product, Misc. (or another) radio_button once off, always off until I run the code again...

Message 5 of 8
andkal
in reply to: jotaferrer

If it is a list box then I think it is a little bit harder but possible. I would do it this way
(action_tile "ANGLE EQ LEG" "(NEW_FUNCTION)" )
And in the function NEW_FUNCTION you would have to write a program thaht reads what is selected in the list box by
(get_tile "ANGLE EQ LEG"). It returns a string with a numbers of selected items fe.  "2" or "0 3 6" (when multiple select is enabled).
Ten you would have to write a conditions

(cond
  ( (= (get_tile "ANGLE EQ LEG") "") (mode_tile "1" 0) (mode_tile "2" 1) (mode_tile "3" 1) ...)
  ( (= (get_tile "ANGLE EQ LEG") "0") (mode_tile "1" 1) (mode_tile "2" 0) (mode_tile "3" 1) ...)
  ( (= (get_tile "ANGLE EQ LEG") "1") (mode_tile "1" 1) (mode_tile "2" 1) (mode_tile "3" 0) ...)
  ( (= (get_tile "ANGLE EQ LEG") "2") ...)
an so on...
)


Maybe it can be writter shorter but this is just to give you an idea.


• www.autolisps.blogspot.com - Productivity plugins for Autocad and Autocad MEP
• Autodesk AppStore
Message 6 of 8
jotaferrer
in reply to: andkal

NAILED IT!

I do have to create a cond for each specific list_box line, but it's doable! 

Thankssss!!!!

 

 

Message 7 of 8
Sea-Haven
in reply to: jotaferrer

This sounds like your maybe creating your own version of "Wiseys steel shapes" which has lots of steel shapes already done.

Message 8 of 8
jotaferrer
in reply to: Sea-Haven

Thanks for sharing this! I think I took a look unto it a while ago, but I need something more simple which also follow our company standards. But I think maybe I'll start using that tool also.

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

Post to forums  

Forma Design Contest


AutoCAD Beta