Author Topic: Error is there a solution?  (Read 14210 times)

0 Members and 1 Guest are viewing this topic.

cadmoogle

  • Guest
Error is there a solution?
« on: January 09, 2009, 12:03:45 PM »
; error: string too long on input

A script can be too long?  :cry:

cadmoogle

  • Guest
Re: Error is there a solution?
« Reply #1 on: January 09, 2009, 12:09:33 PM »
This is what's stopping the code  :evil:
(setq blk (ssget "x" '((0 . "insert") (2 .
 "4FM_45BEND,
  4X4FM_TEE,
  4X2FM_TEE,
  4FM_45BEND_TOP,
  4X2.75FM_REDUCER,
  4X2.5FM_REDUCER,
  ..........Just imagine a lot more here
  0.625X0.75RE_METER")
  )
 )
)

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9268
Re: Error is there a solution?
« Reply #2 on: January 09, 2009, 12:24:24 PM »
Can you filter better then what your currently doing?
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

cadmoogle

  • Guest
Re: Error is there a solution?
« Reply #3 on: January 09, 2009, 12:33:23 PM »
I tried thinking of different ways, but I need to find these blocks (exact names).

cadmoogle

  • Guest
Re: Error is there a solution?
« Reply #4 on: January 09, 2009, 12:52:54 PM »
Would foreach work on this?

ronjonp

  • Needs a day job
  • Posts: 7027
Re: Error is there a solution?
« Reply #5 on: January 09, 2009, 12:59:30 PM »
Try this:

Code: [Select]
(defun manyblocknames2ss (blocklist / n out ss)
  (setq out (ssadd))
  (foreach name blocklist
    (setq n -1)
    (if (setq ss (ssget "_x" (list (cons 0 "INSERT") (cons 2 name))))
      (repeat (sslength ss)
(ssadd (ssname ss (setq n (1+ n))) out)
      )
    )
  )
  (if (zerop (sslength out))
    nil
    out
  )
)
(manyblocknames2ss '("4FM_45BEND" "4X4FM_TEE"))
« Last Edit: January 09, 2009, 03:00:42 PM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

dustinthiesse

  • Guest
Re: Error is there a solution?
« Reply #6 on: January 09, 2009, 01:14:16 PM »
(setq blk (ssget "x" '((0 . "insert") (2 .
 "4FM_45BEND,
  4X4FM_TEE,
  4X2FM_TEE,
  4FM_45BEND_TOP,
  4X2.75FM_REDUCER,
  4X2.5FM_REDUCER,
  ..........Just imagine a lot more here
  0.625X0.75RE_METER")
  )
 )
)

Does this even work with those spaces in your long string?

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9268
Re: Error is there a solution?
« Reply #7 on: January 09, 2009, 01:38:21 PM »
(setq blk (ssget "x" '((0 . "insert") (2 .
 "4FM_45BEND,
  4X4FM_TEE,
  4X2FM_TEE,
  4FM_45BEND_TOP,
  4X2.75FM_REDUCER,
  4X2.5FM_REDUCER,
  ..........Just imagine a lot more here
  0.625X0.75RE_METER")
  )
 )
)

Does this even work with those spaces in your long string?


*blink*
Holly cow, your right! I didnt even notice that. Awesome eye d-unit.

The format is something like:
Code: [Select]
(setq blk
  (ssget
     "x"
     '((0 . "insert")
     (2 . "4FM_45BEND,4X4FM_TEE,4X2FM_TEE,4FM_45BEND_TOP 4X2.75FM_REDUCER,4X2.5FM_REDUCER,..."))) )
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

cadmoogle

  • Guest
Re: Error is there a solution?
« Reply #8 on: January 09, 2009, 02:25:08 PM »
The shorter version works fine with the spaces, but the second I place all of the names in it prompts the error.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Error is there a solution?
« Reply #9 on: January 09, 2009, 02:27:12 PM »
I don't think the name string can be longer than 255 characters.

This wasn't the case.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7027
Re: Error is there a solution?
« Reply #10 on: January 09, 2009, 02:29:58 PM »
The shorter version works fine with the spaces, but the second I place all of the names in it prompts the error.


Use my solution then  :-P

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

cadmoogle

  • Guest
Re: Error is there a solution?
« Reply #11 on: January 09, 2009, 02:35:34 PM »
I did  :-D, but I'm still trying to figure out why I can format long ways in yours but not mine...

cadmoogle

  • Guest
Re: Error is there a solution?
« Reply #12 on: January 09, 2009, 02:45:24 PM »
Ron when I ron the code you provided it's trigger the prompt alert with out finding the blocks even if the drawing is blank. Did I do something wrong?

Code: [Select]
;;NewClose command based off existing blocks
::Cadmoogle - 2009
(defun c:NewClose (/)
(command "-purge" "all" "" "N")
(defun manyblocknames2ss (blocklist / n out ss)
  (setq out (ssadd))
  (foreach name blocklist
    (setq n -1)
    (if (setq ss (ssget "_x" (list (cons 0 "INSERT") (cons 2 name))))
      (repeat (sslength ss)
        (ssadd (ssname ss (setq n (1+ n))) out)
      )
    )
  )
  out
)
(manyblocknames2ss
   '("4FM_45BEND");
(progn
  (alert "** Warning ** Non-standard blocks found in drawing. Rename the blocks to the appropriate names and try again. This includes adding the numbers to fire hydrants and/or adding the as-built number to the prefix of the block(s) name. If this is a design drawing rename, the blocks to reflect a design not an as-built.")
 (exit)
);end 1st progn
 (if
  (setq blk (ssget "x" '((0 . "insert") (2 .
  "*WM_FIREHYD_,
   *WM_FIREHYD_1,
   *WM_FIREHYD_2,
   *WM_FIREHYD_3,
   *WM_FIREHYD_4,
   *WM_FIREHYD_5")
  )
 )
)
   (progn
    (alert "Fire hydrants were located into the drawing that were not properly named, please correct and try again.")
  (exit)
);end 2nd progn
 (progn
  (alert "All standard blocks found in drawing.... Now closing")
  (vla-sendcommand
  (vla-get-activedocument (vlax-get-acad-object))".close ")
 (princ))
 )
)
)


dustinthiesse

  • Guest
Re: Error is there a solution?
« Reply #13 on: January 09, 2009, 02:50:08 PM »
Ronjon's is the way to go.  The block names there are in list form rather than trying to filter them all out with '((2 . "aaa,bbb,ccc,ddd,eee,...etc.))

Cadmoogle, are you sure your way actually worked with a shorter list?
Try checking the selection set length with (sslength blk) after running and see if you get the correct results.

Here is what I did [with 6 inserts of "testblk1" and 4 inserts of "testblk2"]:

(sslength(setq blk(ssget "x" '((0 . "INSERT")(2 .
"testblk1,testblk2"))))) ;;;returns 10

(sslength(setq blk(ssget "x" '((0 . "INSERT")(2 .
"testblk1,
testblk2")))));;;returns 6...it only counts the first block...maybe because it is looking for " testblk2" or "\ntestblk2"...neither of which exist

Either way, you don't get an error, but the selection set is not what you were expecting.

Or maybe it doesn't even check for those.  I'm not sure if those are valid block names.  Very interesting though.
Might explain that error you were getting though.  Not sure.
« Last Edit: January 09, 2009, 03:03:53 PM by d-unit »

ronjonp

  • Needs a day job
  • Posts: 7027
Re: Error is there a solution?
« Reply #14 on: January 09, 2009, 03:01:16 PM »
I updated the function above to return nil if the ss count = 0.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC