Jump to content

Recommended Posts

Posted (edited)

I am rather new to lisp so just trying out a few things and learning,

 

I'm having issues loading a .dcl file from a folder in my C drive, it can locate the file when the .dcl file is placed inside the root drive but as soon as I put the file into another folder I keep getting this error and struggling to find any other similar posts on any forums

 

I've tried:

  • adding the path into the support files search path

 

 

* Lisp (new_dialog) failed : DCL id = -1, dialog name 'SignalCalculator'nil

 

Code: 

(defun C:SIGNALCALC (/ call_distance dlg-id path)
  (defun call_distance ()
    (setq distance (atof $VALUE))
    (Calculate_green)
    (Calculate_red)
  )
  
  (defun calculate_green ()
    (if (>= distance 195)
      (set_tile "green_time" "50 Seconds"))
    (if (<= distance 195)
      (set_tile "green_time" "45 Seconds"))
    (if (<= distance 135)
      (set_tile "green_time" "40 Seconds"))
    (if (<= distance 75)
      (set_tile "green_time" "35 Seconds"))
  )
  
  (defun calculate_red ()
    (if (>= distance 250)
      (set_tile "red_time" "30 Seconds"))
    (if (<= distance 250)
      (set_tile "red_time" "25 Seconds"))
    (if (<= distance 200)
      (set_tile "red_time" "20 Seconds"))
    (if (<= distance 150)
      (set_tile "red_time" "15 Seconds"))
    (if (<= distance 100)
      (set_tile "red_time" "10 Seconds"))
    (if (<= distance 50)
      (set_tile "red_time" "5 Seconds"))
  )
  
  (setq dlg-id (load_dialog "BricsCAD Scripts\Tools\Dialogs\SignalCalculator.dcl"))
  (new_dialog "SignalCalculator" dlg-id)
  (action_tile "distance" "(call_distance)")
  (start_dialog)
  (unload_dialog dlg-id)
)

 

Edited by Charpzy
Posted

change (setq dlg-id (load_dialog "BricsCAD Scripts\Tools\Dialogs\SignalCalculator.dcl")) to the correct / new path or place 'SignalCalculator.dcl' in a folder that is in one of your support paths (options) and use something like :

(If (setq fn (findfile "SignalCalculator.dcl")) (setq dlg-id (load_dialog fn))   (alert "Dialog SignalCalculator.dcl not found"))

  • Like 1
Posted

I can imagine merging dcl in your lisp file can be a little overwhelming when you're new to lisping but then again, we've all been there 🤓

  • Like 1
Posted

@Charpzy btw , you know about difference between / and \\? either you use "c:\\your-path\\SignalCalculator.dcl" or "c:/your-path/SignalCalculator.dcl" because in ...Scripts\Tools\... the \T will be interpreted as a tab.

Posted
1 hour ago, rlx said:

I can imagine merging dcl in your lisp file can be a little overwhelming when you're new to lisping but then again, we've all been there 🤓

 

however with a little guidance it shouldn't be too hard if you can make a separate DCL file on the fly and use that.

 

I use this, below, as a template, working through it to make them up as I need to. This is based on stuff from Lee Mac (and he should have the credit for that). Better check that there are no typos in there too.

 

The basic idea is to make a temporary DCL file vi the LISP routine, I tend to save them in the windows temp folder (getvar "tempprefix"), and every now and then clear that. I'll also tend to call each DCL file a unique name for that LISP, and I have started adding a line to delete any previous temp files of that name before the LISP creates a new one.

 

You can use any method you want to create the DCL file (which is a text file with an extension .dcl), the example below is credit to Lee Mac - I took out this code from one of his.

 

 

(defun c:aDCL( / dcl des dch x)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Put preliminary bits here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  create DCL pop up box   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (if
    (and
      (setq dcl (strcat (getvar "TEMPPREFIX") "DCL.dcl")) ;;rename DCL file as necessary
      (setq des (open dcl "w"))
      (foreach x
        '(
"         pass : dialog { key = \"DialogueKey\";  label = \"Dialogue Label\"; " 
"           spacer;"


;;;;; Add DCL tiles here ;;;;;



;;Building Block Examples:
"  : boxed_column { label = \"\"; width = 60; "
"  }"

"  : row {alignment = top; wisth = 30; "
"  }"

"  : text { key = \"TextKey\";}"
"  : image_button { key = \"ImgButton\"; label = \"Image Button\"; alignment = centered; height = 5; width = 10; fixed_width = true; fixed_height = true;}"
"  : toggle {key = \"Toggle\"; label = \"Toggle\"; alignment = left; value = 1;}"
"  : edit_box { key = \"EditBox\"; label = \"Edit Box\"; width = 25; fixed_width = true;}"
"  : popup_list { key = \"Popup_list\"; label = \"Popup List\"; height = 6; fixed_height = true; width = 22; fixed_width = true;}"
"  : list_box {key = \"ListBox\"; label = \"list Box\"; height = 12; fixed_height = true; width = 38; }"

"  : button { key = \"OK\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 20; }"
"  : button { key = \"cancel\"; label = \"Cancel\"; is_default = false; is_cancel = true; fixed_width = true; width = 20; }"

;;;;; End DCL tiles here;;;;;


"         }"               ;; End pass : dialog
        )                  ;; end '(
        (write-line x des)
      )                    ;;end foreach x
      (not (setq des (close des)))
      (< 0 (setq dch (load_dialog dcl)))
      (new_dialog "pass" dch)
    )                      ;;End of DCL 'and'

    (progn


;;;;; Add Tile actions here ;;;;;;


      (set_tile "TextKey" "text")
      (action_tile "OK" "(done_dialog 1)") ;;can change variables here or run other code
      (action_tile "cancel" "(done_dialog 0)")

;;;;;end tile actions here;;;;;


      (start_dialog)
    ) ;;end of DCL 'progn' above
    (princ "\nError. Unable to load dialogue box.")
  ) ;;end of DCL 'if' above
  (vl-file-delete dcl) ;;delete the temp DCL file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    End DCL pop up box    ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  Add rest of code here   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(princ "OK")
)

 

  • Like 1
Posted

Agree with mhupp I have tried the code and it works well, I just changed where the code/dcl/lsp was written to.

 

Can you post an image of the dcl, if its a get values only then have  a look at my library Multi Getval.lsp its in Downloads here. It writes the code to temporary file on the fly when used.

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