Author Topic: Can't locate error  (Read 1745 times)

0 Members and 1 Guest are viewing this topic.

zombies640

  • Guest
Can't locate error
« on: September 26, 2016, 11:01:52 AM »
How this is supposed to work is the user will first select objects, then run the command. The routine will determine if either "DEC" or "CNF" is in the point description. If it is, place a block and some text.

Not sure why this is giving me an error now. It looks like it only errors after the IF statement triggers TRUE:
Code: [Select]
Command: ; error: no function definition: nil
Code: [Select]
(defun c:desc2 (/ ss x northng pnt eastng descr)
   (vl-load-com)
   (if (ssget ":S:E" '((0 . "AECC_COGO_POINT")))
      (progn
         (vlax-for x
            (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
            (setq pnt (vlax-get x 'number)
               eastng (vlax-get x 'easting)
               northng (vlax-get x 'northing)
               descr (vlax-get x 'rawdescription)
            );END setq
            (if
               (or
                  (= 0 (vl-string-search "DEC" descr))
                  (= 0 (vl-string-search "CNF" descr))
               );END or
               (
                  (command "text" "c" (list eastng northng) 0.5 0 descr)
                  (command "-insert" "nf_shrub_conifer" (list eastng northng) "" "" "")                 
               );END if TRUE
            );END if
         );END vlax-for
      );END progn
   );END if
   (princ)
)

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Can't locate error
« Reply #1 on: September 26, 2016, 11:22:33 AM »
Can't test it as I don't have Civil, but I suppose you forgot to put (progn after (if (condition)...

(defun c:desc2 (/ ss x northng pnt eastng descr)
   (vl-load-com)
   (if (ssget ":S:E" '((0 . "AECC_COGO_POINT")))
      (progn
         (vlax-for x
            (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
            (setq pnt (vlax-get x 'number)
               eastng (vlax-get x 'easting)
               northng (vlax-get x 'northing)
               descr (vlax-get x 'rawdescription)
            );END setq
            (if
               (or
                  (= 0 (vl-string-search "DEC" descr))
                  (= 0 (vl-string-search "CNF" descr))
               );END or
               (progn
                  (command "text" "c" (list eastng northng) 0.5 0 descr)
                  (command "-insert" "nf_shrub_conifer" (list eastng northng) "" "" "")                 
               );END if TRUE
            );END if
         );END vlax-for
      );END progn
   );END if
   (princ)
)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

zombies640

  • Guest
Re: Can't locate error
« Reply #2 on: September 26, 2016, 11:27:41 AM »
Yup, that works. As you were replying, I was trying this instead

Changed:
Code: [Select]
               (
                  (command "text" "c" (list eastng northng) 0.5 0 descr)
                  (command "-insert" "nf_shrub_conifer" (list eastng northng) "" "" "")                 
               );END if TRUE

To:
Code: [Select]
               (command "text" "c" (list eastng northng) 0.5 0 descr
                    "_insert" "nf_shrub_conifer" (list eastng northng) "" "" ""
               );END if true

I like your method better...it's so much celaner. I didn't know you had to use PROGN for separate commands. Now I know! Thanks :)

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Can't locate error
« Reply #3 on: September 26, 2016, 12:09:20 PM »
You're welcome...

BTW. The code you posted looks like there already was written progn, but someone deliberately or not removed it from apparent place inside it...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

PKENEWELL

  • Bull Frog
  • Posts: 317
Re: Can't locate error
« Reply #4 on: September 27, 2016, 09:38:49 AM »
I like your method better...it's so much celaner. I didn't know you had to use PROGN for separate commands. Now I know! Thanks :)

NOTE: The (progn) function is is used to combine multiple programming statements into a single output. The reason you have to use it in the IF statement is because IF can only evaluate 1 output for each If / Then and Else combination.
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Can't locate error
« Reply #5 on: September 27, 2016, 10:07:06 AM »
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox