Jump to content

Need Help with DCL


neo

Recommended Posts

Hello members ,

This is my first post in CADTUTOR ,well I Need Help with my DCL Codes

I was Created Lisp with Dialog Box , and I got one problem here ,which is how to save user settings , if I select one toggle key, same time I am going to select text objects ,when the Dialog box return ,my toggle selection is showing unselected Please help .....

 

Lisp Codes

(defun switch (/ mod)
 (setq mod(atoi (get_tile "left")))
 (if (= mod 1)
     (mode_tile "right" 1)
     (mode_tile "right" 0)
 )
)

(defun switch2(/ mod2)
 (setq mod2(atoi (get_tile "right")))
 (if (= mod2 1)
   (mode_tile "left" 1)
   (mode_tile "left" 0)
 )
)

(defun savevars (l r sset e / sname ent new_txt)
    (repeat (setq s (sslength sset))
      (setq sname (ssname sset (setq s (1- s))))
      (setq ent (entget sname))
      (if (= l 1)
          (setq new_txt(vl-string-left-trim e (cdr (assoc 1 ent))))
   (setq new_txt(vl-string-right-trim e (cdr (assoc 1 ent))))
      )
  
      (entmod (subst (cons 1 new_txt) (assoc 1 ent) ent))
      (entupd (cdr (assoc -1 ent)))
    )
 (princ))



(defun c:trim_t (/ counter dcl_id lft rht ed obj)
 (setq counter 3)
 (while (> counter 2)
 (if (not (setq dcl_id (load_dialog "C:\\Text Trim.dcl")))
   (progn
     (alert "Could not be find Dcl file")
     (exit)
   )
 
 (progn
   (if (not (new_dialog "Trim" dcl_id))
     (progn
(alert "The definition could not be found inside the DCL file")
(exit)
     )
   
   (progn
     (action_tile "left" "(setq lft (atoi(get_tile\"left\"))) (switch)")
     (action_tile "right" "(setq rht (atoi(get_tile\"right\"))) (switch2)")
     (action_tile "edit" "(setq ed (get_tile \"edit\"))")
     (action_tile "apply" "(done_dialog 1)")
     (action_tile "cancel" "(done_dialog 0)")
     (action_tile "select objects" "(done_dialog 3)")
     (setq counter (start_dialog))

     (cond
((= counter 1) (savevars lft rht obj ed))
((= counter 0) (princ "\n...Function cancelled."))
((= counter 3) (setq obj (ssget '((0 . "TEXT")))))
     )
   )
     )
   )
   )
   )
(unload_dialog dcl_id)
(princ))
     

 

Dialog Codes

Trim: dialog {label= "Trim String 1.0";
              :boxed_radio_row {
              :text {label="                 Select Objects";}
              :button{label=" > > ";key="select objects";width=0.5;height=3 ;}
              }
              : boxed_radio_row {
                 
                    :toggle {label="Trim from Left";key="left";value=0;}
                    :toggle {label="Trim from Right";key="right";value=0;}
                    }
                    :edit_box{label="Type String ";key="edit";edit_limit=true;edit_width=30;allow_accept=true;}
                     :boxed_radio_row{

                   :button{label="Apply";key="accept";alignment=centered ;width=12 ;is_default=true;}
                   :button{label="Cancel";key="cancel";alignment=centered;width=12;is_default=false;is_cancel=true;}

                   }
            }
              

Link to comment
Share on other sites

Try this code :-

 

(defun savevars	(l r sset e / sname ent new_txt)
 (repeat (setq s (sslength sset))
   (setq sname (ssname sset (setq s (1- s))))
   (setq ent (entget sname))
   (if	(= l 1)
     (setq new_txt (vl-string-left-trim e (cdr (assoc 1 ent))))
     (setq new_txt (vl-string-right-trim e (cdr (assoc 1 ent))))
   )

   (entmod (subst (cons 1 new_txt) (assoc 1 ent) ent))
   (entupd (cdr (assoc -1 ent)))
 )
 (princ)
)



(defun c:trim_t (/ counter dcl_id lft rht ed obj)
 (setq counter 3)

 (if (not *MyToggles@)
   (setq *MyToggles@ (list nil "0" "0"))
 )
 (setq	left  (nth 1 *MyToggles@)
right (nth 2 *MyToggles@)
 )

 (while (> counter 2)
   (if	(not (setq dcl_id (load_dialog "C:\\Text Trim.dcl")))
     (progn
(alert "Could not be find Dcl file")
(exit)
     )
   )


   (if	(not (new_dialog "Trim" dcl_id))
     (progn
(alert
  "The definition could not be found inside the DCL file"
)
(exit)
     )
   )

   (defun switch (/ mod)
     (setq mod (atoi (get_tile "left")))
     (if (= mod 1)
(mode_tile "right" 1)
(mode_tile "right" 0)
     )
   )

   (defun switch2 (/ mod2)
     (setq mod2 (atoi (get_tile "right")))
     (if (= mod2 1)
(mode_tile "left" 1)
(mode_tile "left" 0)
     )
   )

   (defun set_defaults	()
     (set_tile "right" right)
     (set_tile "left" left)
     (set_tile "edit" "")
   )

   (progn
     (set_defaults)
     (action_tile "left" "(setq left $value) (switch)")
     (action_tile "right" "(setq right $value) (switch2)")
     (action_tile "edit" "(setq ed (get_tile \"edit\"))")
     (action_tile "apply" "(done_dialog 1)")
     (action_tile "cancel" "(done_dialog 0)")
     (action_tile "select objects" "(done_dialog 3)")
     (setq counter (start_dialog))

     (cond
((= counter 1) (savevars left left obj ed))
((= counter 0) (princ "\n...Function cancelled."))
((= counter 3) (setq obj (ssget '((0 . "TEXT")))))
     )
   )
 )
 (unload_dialog dcl_id)

 (princ)
)

Link to comment
Share on other sites

Try this code :-

 

(defun savevars	(l r sset e / sname ent new_txt)
 (repeat (setq s (sslength sset))
   (setq sname (ssname sset (setq s (1- s))))
   (setq ent (entget sname))
   (if	(= l 1)
     (setq new_txt (vl-string-left-trim e (cdr (assoc 1 ent))))
     (setq new_txt (vl-string-right-trim e (cdr (assoc 1 ent))))
   )

   (entmod (subst (cons 1 new_txt) (assoc 1 ent) ent))
   (entupd (cdr (assoc -1 ent)))
 )
 (princ)
)



(defun c:trim_t (/ counter dcl_id lft rht ed obj)
 (setq counter 3)

 (if (not *MyToggles@)
   (setq *MyToggles@ (list nil "0" "0"))
 )
 (setq	left  (nth 1 *MyToggles@)
right (nth 2 *MyToggles@)
 )

 (while (> counter 2)
   (if	(not (setq dcl_id (load_dialog "C:\\Text Trim.dcl")))
     (progn
(alert "Could not be find Dcl file")
(exit)
     )
   )


@

   (if	(not (new_dialog "Trim" dcl_id))
     (progn
(alert
  "The definition could not be found inside the DCL file"
)
(exit)
     )
   )

   (defun switch (/ mod)
     (setq mod (atoi (get_tile "left")))
     (if (= mod 1)
(mode_tile "right" 1)
(mode_tile "right" 0)
     )
   )

   (defun switch2 (/ mod2)
     (setq mod2 (atoi (get_tile "right")))
     (if (= mod2 1)
(mode_tile "left" 1)
(mode_tile "left" 0)
     )
   )

   (defun set_defaults	()
     (set_tile "right" right)
     (set_tile "left" left)
     (set_tile "edit" "")
   )

   (progn
     (set_defaults)
     (action_tile "left" "(setq left $value) (switch)")
     (action_tile "right" "(setq right $value) (switch2)")
     (action_tile "edit" "(setq ed (get_tile \"edit\"))")
     (action_tile "apply" "(done_dialog 1)")
     (action_tile "cancel" "(done_dialog 0)")
     (action_tile "select objects" "(done_dialog 3)")
     (setq counter (start_dialog))

     (cond
((= counter 1) (savevars left left obj ed))
((= counter 0) (princ "\n...Function cancelled."))
((= counter 3) (setq obj (ssget '((0 . "TEXT")))))
     )
   )
 )
 (unload_dialog dcl_id)

 (princ)
)

 

 

 

satishrajdev That was brilliant , Thank So much for Helping Me to fix This

 

5 Stars

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...