Jump to content

Recommended Posts

Posted

I am creating a lisp for our rev box and using LispVariables in fields to store the rev data in the drawing. I have done this before the our user info box using drop down lists and it works fine. As soon as I launch that one it reads the variables from the drawing and updates the dialog box. I am using edit boxes in this one but they don't update to the values within the drawing each time I run it.

Can anyone help with this please?

Also is there a way that I can control visibility state of a block based on the first edit box containing anything other than "---"?

 

 
Rev_box : dialog {    //dialog name
     label = "Drawing Revisions" ;  //give it a label
//////////////////////////////////////////////////////////////////////////////////////////// 
       :row {    //define boxed row
//********************************************************* 
      : edit_box {    //define edit box
        key = "ccc_rev1" ;   //give it a name
        label = "Rev" ;   //give it a label
        edit_limit = 2 ;   //6 characters only
        edit_width = 2 ;   //6 characters only
       }
//*********************************************************  
      : edit_box {    //define edit box
        key = "ccc_by1" ;   //give it a name
        label = "By" ;   //give it a label
        edit_limit = 3 ;   //6 characters only
        edit_width = 3 ;   //6 characters only
        }
//********************************************************* 
      : edit_box {    //define edit box
        key = "ccc_date1" ;   //give it a name
        label = "Date" ;   //give it a label
        edit_limit = 10 ;   //6 characters only
        edit_width = 9 ;   //6 characters only
        }
//********************************************************* 
      : edit_box {    //define edit box
        key = "ccc_des1" ;   //give it a name
        label = "Description" ;   //give it a label
        edit_limit = 58 ;   //6 characters only
        edit_width = 42 ;   //6 characters only
        }
//*********************************************************
       :toggle {    //define toggle
       key = "ccc_tog1";    //give it a name
       label = "Line 1";   //give it a label
       }     //end toggle
//*********************************************************  
       }     //end boxed row
ok_cancel ;    //predifined OK/Cancel
    
    }      //end dialog

 

 
(defun C:rev_box ()     ;define function
 (setq dcl_id (load_dialog "rev_box.dcl"))  ;load dialog
 (if (not (new_dialog "rev_box" dcl_id)   ;test for dialog
     )
   (exit)      ;exit if no dialog

 );if
     (action_tile
   "cancel"      ;if cancel button pressed
   "(done_dialog) (setq userclick nil)"  ;close dialog, set flag
   );action_tile
  (action_tile
   "accept"      ;if O.K. pressed
   " (done_dialog)(setq userclick T))"   ;close dialog, set flag
 );action tile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(action_tile "ccc_rev1" "(setq ccc_rev_1 $value)")
(action_tile "ccc_by1" "(setq ccc_by_1 $value)")
(action_tile "ccc_date1" "(setq ccc_date_1 $value)")
(action_tile "ccc_des1" "(setq ccc_des_1 $value)")

 (start_dialog)     ;start dialog
  (unload_dialog dcl_id)    ;unload
(princ)
(command "regenall")
);defun C:samp
(princ)

Posted

I have tried to force the tile handle to accept the value of the variable in CAD. I have used this:

 

 
(defun C:rev_box ()     ;define function
 (setq dcl_id (load_dialog "rev_box.dcl"))  ;load dialog
 (if (not (new_dialog "rev_box" dcl_id)   ;test for dialog
     )
   (exit)      ;exit if no dialog
[color=red] (setq ccc_rev1 ccc_rev_1) 
[/color]  );if
     (action_tile
   "cancel"      ;if cancel button pressed
   "(done_dialog) (setq userclick nil)"  ;close dialog, set flag
   );action_tile
  (action_tile
   "accept"      ;if O.K. pressed
   " (done_dialog)(setq userclick T))"   ;close dialog, set flag
 );action tile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(action_tile "ccc_rev1" "(setq ccc_rev_1 $value)")
(action_tile "ccc_by1" "(setq ccc_by_1 $value)")
(action_tile "ccc_date1" "(setq ccc_date_1 $value)")
(action_tile "ccc_des1" "(setq ccc_des_1 $value)")

 (start_dialog)     ;start dialog
  (unload_dialog dcl_id)    ;unload
(princ)
(command "regenall")
);defun C:samp
(princ)

 

Can this even be done or am I whistling against the wind?

Posted

So I've spotted some of my mistakes.

 

It should be as follows:

 

 
(defun C:rev_box ()     ;define function
 (setq dcl_id (load_dialog "rev_box.dcl"))  ;load dialog
 (if (not (new_dialog "rev_box" dcl_id)   ;test for dialog
     )
   (exit)      ;exit if no dialog
 );if

[color=red](set_tile "ccc_rev1" ccc_rev_1)[/color] 
     (action_tile
   "cancel"      ;if cancel button pressed
   "(done_dialog) (setq userclick nil)"  ;close dialog, set flag
   );action_tile
  (action_tile
   "accept"      ;if O.K. pressed
   " (done_dialog)(setq userclick T))"   ;close dialog, set flag
 );action tile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(action_tile "ccc_rev1" "(setq ccc_rev_1 $value)")
(action_tile "ccc_by1" "(setq ccc_by_1 $value)")
(action_tile "ccc_date1" "(setq ccc_date_1 $value)")
(action_tile "ccc_des1" "(setq ccc_des_1 $value)")

 (start_dialog)     ;start dialog
  (unload_dialog dcl_id)    ;unload
(princ)
(command "regenall")
);defun C:samp
(princ)

 

This works fine within a drawing but when I save it, close it and then go back in I get the following error when I run it:

; error: bad argument type: stringp nil

 

Antone any ideas?

Posted

try setq ccc_rev_1 in the lisp.

 

try something like:

 
(defun C:rev_box (/ dcl_id ccc_rev1) 
[color=darkred][b](setq ccc_rev1 ???)[/b][/color]
;;and so on...

 

 

ps

edit posts so other users do not have to read through all your posts to give their input.

Posted

Thanks Lt Dan's Legs but that didn't work. The problem seems to be that when I input values in the dialog these are created as LispVariables in CAD and I have fields setup with these variables. If I then save the drawing and reopen it the fields still contain the variable on the top of the far right field dialog but they are no longer in the list of variables. Is there any way around this? Is there a way that I can get CAD to save the fields in the drawing?

 

Rev Box Variables.PNG

Posted

Is there some way that I can get CAD to store the fields after the lisp has finished so that when I open the drawing again they are still there and get passed to the DCL and appear in the correct edit box.

Posted

There has been discussion before about storing data in a dwg search for extended entities. Also have a look at useri1-5 userr1-5 users1-5.

Posted
So I've spotted some of my mistakes.

 

It should be as follows:

 

 
(defun C:rev_box () ;define function
(setq dcl_id (load_dialog "rev_box.dcl")) ;load dialog
(if (not (new_dialog "rev_box" dcl_id) ;test for dialog
)
(exit) ;exit if no dialog
);if

[color=red](set_tile "ccc_rev1" ccc_rev_1)[/color] 
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog) (setq userclick nil)" ;close dialog, set flag
);action_tile
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T))" ;close dialog, set flag
);action tile
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(action_tile "ccc_rev1" "(setq ccc_rev_1 $value)")
(action_tile "ccc_by1" "(setq ccc_by_1 $value)")
(action_tile "ccc_date1" "(setq ccc_date_1 $value)")
(action_tile "ccc_des1" "(setq ccc_des_1 $value)")

(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(princ)
(command "regenall")
);defun C:samp
(princ)

 

This works fine within a drawing but when I save it, close it and then go back in I get the following error when I run it:

; error: bad argument type: stringp nil

 

Antone any ideas?

 

woodman78,

 

This works. Also note I took out all those useless comments and made tile changes. This was your problem (set_tile "ccc_rev1" ccc_rev_1) .

Also changed this Rev_box to this rev_box.

 

 

 

Dialog

[color=red]rev_box[/color] : dialog { label = "Drawing Revisions";
         : row  {
           : edit_box { label = "Rev";         key = "ccc_rev1";  edit_limit = 2;  edit_width = 2;  }
           : edit_box { label = "By" ;         key = "ccc_by1" ;  edit_limit = 3;  edit_width = 3;  }
           : edit_box { label = "Date";        key = "ccc_date1"; edit_limit = 10; edit_width = 9;  }
           : edit_box { label = "Description"; key = "ccc_des1";  edit_limit = 58; edit_width = 42; }
           : toggle   { label = "Line 1";      key = "ccc_tog1";  }
         }
[color=red]          : button { label = "&Ok";   key = "accept"; width = 18; fixed_width = true; alignment = centered; is_default = true; }  [/color]
[color=red]          : button { label = "&Exit"; key = "cancel"; width = 18; fixed_width = true; alignment = centered; is_cancel = true;  }[/color]
[color=red]        }[/color]

 

 

Lisp

(defun C:rev_box ()
 [color=red](or ccc_rev_1 (setq ccc_rev_1 "1"))[/color]
 (setq dcl_id (load_dialog "rev_box.dcl"))
 (if (not (new_dialog "rev_box" dcl_id))
   (exit))
 (set_tile [color=red]"ccc_rev1"[/color] ccc_rev_1) 
 (action_tile "ccc_rev1"  "(setq ccc_rev_1  $value)")
 (action_tile "ccc_by1"   "(setq ccc_by_1   $value)")
 (action_tile "ccc_date1" "(setq ccc_date_1 $value)")
 (action_tile "ccc_des1"  "(setq ccc_des_1  $value)")
 (action_tile "cancel"    "(done_dialog)(setq userclick nil)")
 (action_tile "accept"    "(done_dialog)(setq userclick T))")
 (start_dialog)
 (unload_dialog dcl_id)
[color=red] (if userclick[/color]
[color=red]  (progn[/color]
[color=red]    (command "._regenall")))[/color]
[color=red](princ))[/color]

Posted (edited)
Is there some way that I can get CAD to store the fields after the lisp has finished so that when I open the drawing again they are still there and get passed to the DCL and appear in the correct edit box.

 

 

See here: http://www.afralisp.net/archive/lispa/lisp50.htm

Edited by The Buzzard
Posted

The code below is called RBOX, and has all your tiles setup and filled in with default data. Note that they are setup as global variables. Trying to save you some time.

This is only good for the current drawing session. For data saved from the last drawing session every time you open the drawing, See the links in the post above.

 

RBOX.dcl

RBOX : dialog { label = "Drawing Revisions";
      : row  {
        : edit_box { label = "Rev";         key = "ccc_rev1";  edit_limit = 2;  edit_width = 2;  }
        : edit_box { label = "By" ;         key = "ccc_by1" ;  edit_limit = 3;  edit_width = 3;  }
        : edit_box { label = "Date";        key = "ccc_date1"; edit_limit = 10; edit_width = 9;  }
        : edit_box { label = "Description"; key = "ccc_des1";  edit_limit = 58; edit_width = 42; }
        : toggle   { label = "Line 1";      key = "ccc_tog1";  }
      }
      : button { label = "&Ok";   key = "accept"; width = 18; fixed_width = true; alignment = centered; is_default = true; }  
      : button { label = "&Exit"; key = "cancel"; width = 18; fixed_width = true; alignment = centered; is_cancel = true;  }
    }

 

RBOX.lsp

 

(defun C:RBOX ()
 (or RBOX:ccc_rev_1  (setq RBOX:ccc_rev_1  "1"))
 (or RBOX:ccc_by_1   (setq RBOX:ccc_by_1   "WM"))
 (or RBOX:ccc_date_1 (setq RBOX:ccc_date_1 "10/22/10"))
 (or RBOX:ccc_des_1  (setq RBOX:ccc_des_1  "ISSUED FOR CONSTRUCTION"))
 (or RBOX:ccc_tog_1  (setq RBOX:ccc_tog_1  "1"))
 (setq dcl_id (load_dialog "RBOX.dcl"))
 (if (not (new_dialog "RBOX" dcl_id))
   (exit))
 (set_tile "ccc_rev1"  RBOX:ccc_rev_1)
 (set_tile "ccc_by1"   RBOX:ccc_by_1)
 (set_tile "ccc_date1" RBOX:ccc_date_1)
 (set_tile "ccc_des1"  RBOX:ccc_des_1)
 (set_tile "ccc_tog1"  RBOX:ccc_tog_1)
 (action_tile "ccc_rev1"  "(setq RBOX:ccc_rev_1  $value)")
 (action_tile "ccc_by1"   "(setq RBOX:ccc_by_1   $value)")
 (action_tile "ccc_date1" "(setq RBOX:ccc_date_1 $value)")
 (action_tile "ccc_des1"  "(setq RBOX:ccc_des_1  $value)")
 (action_tile "ccc_tog1"  "(setq RBOX:ccc_tog_1     $value)")
 (action_tile "cancel"    "(done_dialog)(setq userclick nil)")
 (action_tile "accept"    "(done_dialog)(setq userclick T))")
 (start_dialog)
 (unload_dialog dcl_id)
 (if userclick
   (progn
     (command "._regenall")))
 (princ))

Posted

Thanks Buzzard for all your others and those others who contributed too. It's great. I'll look into storing the variable data outside the drawing session and see if I can get it to work.

 

Thanks again.

Posted

Thanks for your help on this one Buzzard. I got the variables store fine in the cfg file. It opens up many possibilities. Thanks again Buzzard and everyone else who contributed.:wink:

Posted

I've just spotted a drawback with this which could make it useless for my purpose. I was trying to use it for a rev box. The problem is that I have rev boxes in many drawings. It I set my rev in the rev box to be G1 in drawing 1 and G2 in drawing 2 when I go back into drawing 1 and run rbox it will display G2 as the variable held in the cfg file even though G1 is in the drawing!!

 

Is there any other way around this?

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...