Author Topic: Need help with lisp and DCL file (enclosed)  (Read 8223 times)

0 Members and 1 Guest are viewing this topic.

TJAM51

  • Guest
Need help with lisp and DCL file (enclosed)
« on: March 24, 2004, 10:02:16 AM »
I am receiving the following error message :


Command: dh
Error: bad argument type: stringp 1; error: An error has occurred inside the
*error* functionAutoCAD variable setting rejected: "filletrad" nil

The DCL file and lisp code are below.......need help figuring this out.

Thanks

DCL Code

dhatch : dialog {
label = "Quick Hatch" ;
: list_box {
label = "Choose Pattern:";
key = "selections";
}
: edit_box {
key = "eb1";
edit_limit = 5;
edit_width = 6;
label = "Hatch Scale:";
}
ok_cancel ;
}



LSP Code:

(defun C:dh (/ hlist dcl_id hat htch usercmd p1 p2 p3 p4 rb ang)
;Make 2D point from 3D point
(defun 3dP->2dP (3dpt) (list (car 3dpt) (cadr 3dpt)))


(setq hlist '("ANSI31" "ANSI32" "ANSI37" "ANSI38" "AR-CONC" "AR-SAND" "DASH"))

(setq dcl_id (load_dialog "dhatch.dcl"))
(if (not (new_dialog "dhatch" dcl_id))(exit))

(start_list "selections")

(mapcar 'add_list hlist)

(end_list)

(if(= hs nil)(setq hs 1))
(set_tile "eb1" hs)

(action_tile
"accept"
"(setq hat (atof (get_tile \"selections\")))
(setq hs (get_tile \"eb1\"))
(done_dialog) (setq userclick T)")

(action_tile
"cancel"
"(done_dialog) (setq userclick nil)")

(start_dialog)
(unload_dialog dcl_id)
(if userclick

(progn
(setq htch (fix hat))
(setq htch (nth htch hlist))
(if(= hs "")(setq hs "1"))
(setvar "hpscale" (atoi hs))



(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(prompt "\nPick boundry points to hatch")
(setq p1 (getPoint "\nPick first point:")
p2 (getPoint p1 "\nPick along Pipe first:")
p3 (getPoint p2 "\nPick across Pipe:")
p1 (3dP->2dP p1)
p2 (3dP->2dP p2)
p3 (3dP->2dP p3)
p4 (polar p1 (angle p2 p3) (distance p2 p3))
RB "N" ; Retain Border

ang (* 180.0 (/ (+ (angle p1 p2) (* pi 0.5)) pi))
)
(command "_.hatch" htch "" ang "" RB p1 p2 p3 p4 "close" "")
(setvar "CMDECHO" usercmd)
(princ)))
)
(prompt "\nPipe Hatch routine loaded. Enter PipeH3 to run.")
(Princ)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Need help with lisp and DCL file (enclosed)
« Reply #1 on: March 24, 2004, 10:15:48 AM »
See the resolution on the other forum you posted to. Also you should know that the same people that visit the other forum also visit here. You should not be impatient in receiving answers. A single post resolves the answer most of the time. Also it helps to make use of the code designations when you post your code...

Example...
Code: [Select]

this is code
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
Need help with lisp and DCL file (enclosed)
« Reply #2 on: March 24, 2004, 10:17:31 AM »
TJAM, let me introduce you to the lisp forum here.
http://www.theswamp.org/phpBB2/viewforum.php?f=2
Not to sound rude, but that is where things of this nature should be. We've set up a whole bunch of forums so that nobody has to search through 100 pages of unrelated topics to get to the one they are looking for. I realize that you're a fairly new poster here and that is why I'm telling you this. Cad General is for non-programming related questions, Vlisp Hackers is for lisp coding questions and show your stuff is for those who'd like to show off what they've written. Thanks for understanding and I hope you come back more often.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Need help with lisp and DCL file (enclosed)
« Reply #3 on: March 24, 2004, 10:38:26 AM »
Looks like something to do with the .dcl code but I'm missing it!
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Need help with lisp and DCL file (enclosed)
« Reply #4 on: March 24, 2004, 10:57:46 AM »
Mark it is the value of hs that is causing the problem. It is being set to an integer, then he is trying to put it into a text_box control in the dcl. It must be a string.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Need help with lisp and DCL file (enclosed)
« Reply #5 on: March 24, 2004, 11:15:51 AM »
.. not to mention a bad error handler  :)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Need help with lisp and DCL file (enclosed)
« Reply #6 on: March 24, 2004, 11:32:36 AM »
It looks like it is trying to set the value of filletrad and for whatever reason, it is failing.
There is no error handler defined in this code so I can only presume that the error handler was written for another program and it was never cleaned up by the calling function. If this is the case, the variable that the error handler is trying to set to filletrad would likely be either not set or set to a data type not allowed.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help with lisp and DCL file (enclosed)
« Reply #7 on: March 24, 2004, 01:19:49 PM »
Try this: but first delete the file you saved called dhatch.dcl

Code: [Select]
(defun c:dh (/ hlist dcl_id hat htch usercmd p1 p2 p3 p4 rb ang)

 ;Make 2D point from 3D point
  (defun 3dp->2dp (3dpt) (list (car 3dpt) (cadr 3dpt)))
  ;; ***********************************************
  ;; create dcl file in same directory as ACAD.PAT
  ;; ***********************************************
  (if (not (findfile "dhatch.dcl"))
    (progn
      (setq acad (findfile "ACAD.PAT")
            acad (strcat (substr acad 1 (- (strlen acad) 8))
                         "dhatch.dcl"
                 )
            acad (open acad "w")
      )
      (foreach x
                 '("dhatch : dialog {"
                   "label = \"Quick Hatch\" ;"
                   "      : list_box {"
                   "      label = \"Choose Pattern:\";"
                   "      key = \"selections\";"
                   "      }"
                   "      : edit_box {"
                   "      key = \"eb1\";"
                   "      edit_limit = 5;"
                   "      edit_width = 6;"
                   "      label = \"Hatch Scale:\";"
                   "      }"
                   "   ok_cancel ;"
                   "}"
                  )
        (princ x acad)
      )
      (close acad)
    )
    nil
  )
  (setq hlist '("ANSI31" "ANSI32" "ANSI37" "ANSI38" "AR-CONC" "AR-SAND"
                "DASH")
  )
  (if (> (setq dcl_id (load_dialog "dhatch.dcl")) 0)
    (if (new_dialog "dhatch" dcl_id)
      (progn

        (start_list "selections")
        (mapcar 'add_list hlist)
        (end_list)
        (if (= hs nil)
          (setq hs "1")
        )
        (set_tile "eb1" hs)
        (action_tile
          "accept"
          "(setq hat (atof (get_tile \"selections\")))
          (setq hs (get_tile \"eb1\")) (done_dialog) (setq userclick T)"
        )
        (action_tile
          "cancel"
          "(done_dialog) (setq userclick nil)"
        )
      ) ; progn
    ) ; endif
    (progn
      (alert "Erro:\n\n\tDialog file could not be loaded...\t\t\n\n")
      (exit)
    )
  ) ; endif
  (start_dialog)
  (unload_dialog dcl_id)
  (if userclick

    (progn
      (setq htch (fix hat))
      (setq htch (nth htch hlist))
      (if (= hs "")
        (setq hs "1")
      )
      (setvar "hpscale" (atoi hs))



      (setq usercmd (getvar "CMDECHO"))
      (setvar "CMDECHO" 0)
      (prompt "\nPick boundry points to hatch")
      (setq p1  (getpoint "\nPick first point:")
            p2  (getpoint p1 "\nPick along Pipe first:")
            p3  (getpoint p2 "\nPick across Pipe:")
            p1  (3dp->2dp p1)
            p2  (3dp->2dp p2)
            p3  (3dp->2dp p3)
            p4  (polar p1 (angle p2 p3) (distance p2 p3))
            rb  "N" ; Retain Border

            ang (* 180.0 (/ (+ (angle p1 p2) (* pi 0.5)) pi))
      )
      (command "_.hatch" htch "" ang "" rb p1 p2 p3 p4 "close" "")
      (setvar "CMDECHO" usercmd)
      (princ)
    )
  )
)
(prompt "\nPipe Hatch routine loaded. Enter DH to run.")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Need help with lisp and DCL file (enclosed)
« Reply #8 on: March 24, 2004, 01:40:25 PM »
hey cab im trying to try this out but where is the seperation between lsp and dcl. i tried to seperate them where you said but get malformed list when i run it?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help with lisp and DCL file (enclosed)
« Reply #9 on: March 24, 2004, 01:45:22 PM »
Hay Dan where you been?

The message to delete the file was for  TJAM51.

DO NOT alter the file posted.

It has the DCL code embedded within it. That is to say this lisp routine
will create the DCl file for you if it doesn't find it.

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

PDJ

  • Guest
Need help with lisp and DCL file (enclosed)
« Reply #10 on: March 24, 2004, 01:55:29 PM »
That's because the lisp routine he wrote creates it's own .dcl file.  

Just load the file, then type DH and you're there..

Nice job CAB, as always..

Paul Jordan
Anchorage, AK

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Need help with lisp and DCL file (enclosed)
« Reply #11 on: March 24, 2004, 02:13:13 PM »
another spin on the first part. :D
Code: [Select]

(defun c:dh (/ dcl-tmpfile hlist dcl_id hat
              htch usercmd p1 p2 p3 p4 rb ang
             )

   (defun dcl-tmpfile (ext)
     (vl-filename-mktemp nil nil (strcat "." ext))
     )

 ;Make 2D point from 3D point
   (defun 3dp->2dp (3dpt) (list (car 3dpt) (cadr 3dpt)))

   (setq dcl_file  (dcl-tmpfile "dcl")
         dcl_write (open dcl_file "w")
   )

   (if dcl_write
     (progn
       (foreach x
                  '("dhatch : dialog {"
                    "label = \"Quick Hatch\" ;"
                    "      : list_box {"
                    "      label = \"Choose Pattern:\";"
                    "      key = \"selections\";"
                    "      }"
                    "      : edit_box {"
                    "      key = \"eb1\";"
                    "      edit_limit = 5;"
                    "      edit_width = 6;"
                    "      label = \"Hatch Scale:\";"
                    "      }"
                    "   ok_cancel ;"
                    "}"
                   )
         (princ x dcl_write)
       )
       (close dcl_write)
     )
   )




   (setq hlist '("ANSI31"     "ANSI32"     "ANSI37"
                 "ANSI38"     "AR-CONC"    "AR-SAND"
                 "DASH"
                )
   )
   (if (> (setq dcl_id (load_dialog dcl_file)) 0)
     (if (new_dialog "dhatch" dcl_id)
................
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help with lisp and DCL file (enclosed)
« Reply #12 on: March 24, 2004, 02:48:25 PM »
Thanks PDJ

Nice twist Mark.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Need help with lisp and DCL file (enclosed)
« Reply #13 on: March 24, 2004, 03:05:07 PM »
ah i see cab i was just skimming through i'll give that a try. i've been dropping by from time to time just sort of busy lately

ELOQUINTET

  • Guest
Need help with lisp and DCL file (enclosed)
« Reply #14 on: March 24, 2004, 03:45:25 PM »
i was interested in this because it looked like you could filter the hatches. i got it to work but didn't really realize it was for piping exclusively. i was wondering how i could modify this so i can filter out the hatch patterns i never use. i'm surpirised autocad hasn't developed this yet into the hatch dialog.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Need help with lisp and DCL file (enclosed)
« Reply #15 on: March 24, 2004, 03:54:36 PM »
Just edit your acad.pat file. back it up first, of course. :D
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help with lisp and DCL file (enclosed)
« Reply #16 on: March 24, 2004, 03:56:24 PM »
Dan,
You can remove the hatch patterns by deleting then from the acad.pat file.

(Back up your files first)

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Need help with lisp and DCL file (enclosed)
« Reply #17 on: March 24, 2004, 03:58:28 PM »
to late CAB........... i beat you to it. :D
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help with lisp and DCL file (enclosed)
« Reply #18 on: March 24, 2004, 04:05:22 PM »
Mark,
You're a turbo typer.... :shock:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Need help with lisp and DCL file (enclosed)
« Reply #19 on: March 24, 2004, 04:24:02 PM »
hey who deleted my hatch patterns, damn you guys are fast.....yeah that's an opiton but it would be nice to have a filter you could easily turn on and off directly. you could add your commonly used patterns and filter the rest out but if you needed one you could uncheck the box and all would show. i'm just thinking aloud  :idea:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Need help with lisp and DCL file (enclosed)
« Reply #20 on: March 24, 2004, 04:45:16 PM »
Just move the unused patterns to a new file "ACAD-2.pat" or what ever.

Then you can find them under the custom tab.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.