I've been trying to get this Lisp to accept a page number and pass it on to the called lisp (PageMe.lsp) . The lisp continues to fail and I've tried adding debugging steps. It currently fails at step6 with the error "too few actual parameters occurred". I don't seem to be able to resolve this error. I've attached the lisp. Can someone help me to resolve this error?
Solved! Go to Solution.
Solved by ec-cad. Go to Solution.
@Markeckert hi,
do not think the following is ok?
(setq sh (vla-getInterfaceObject (vlax-get-acad-object)))
replace it with:
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
i do not see you are using 'sh' in this lisp at all.
Moshe
Thanks, That helped. I now have gotten into the PageMe lisp. It too is failing. I added princ to show how far it gets into the lisp. It gets to Pageme5 but doesn't reach Pageme6. Are you able to determine what might be the issue?
Substitute 'VALUE1' for 'VALUE' in Pageme.lsp.
VALUE by itself, I think is a protected variable name..
ECCAD
And, change
(setq new_dwg (strcat (substr (getvar "dwgname") 1 22) (substr (getvar "value") 1 1) "_" (substr (getvar "dwgname") 18 7)))
To be
(setq new_dwg (strcat (substr (getvar "dwgname") 1 22) value1 "_" (substr (getvar "dwgname") 18 7)))
You may have to work on that 'new_dwg name.
Your original drawing names.
C9730_2012-12-12_p01of04.dwg
For the 'Pageme.lsp if you input 'max_page as say 5..
what do you want for a final drawing name ?
Aactually no such system variable as value so (getvar"value") will return nil.
@Markeckert What exactly are you trying to retrieve?
Paulli,
See pageme.lsp in message 3.
OP wants to put in a max_page into (2) attributes of the block.
Then, OP wants to rename those original drawing names, with a new name, based on the passed in
value of 'max_page.
But I don't know exactly what new drawing name he's wanting.
ECCAD
exactly...if we assume that the value is his variable set here:
(setq new_dwg (strcat (substr (getvar "dwgname") 1 22) (substr value 1 1) "_" (substr (getvar "dwgname") 18 7)))
But for example if value is setq "Page 1 of 2" why would you want to retrieve just the first letter "P" in this case as part of the new name?
Here's the CPNNCA.lsp, with the line:
(setq sh (vla-getInterfaceObject (vlax-get-acad-object)))
removed. It works now.
ECCAD
Yes, you are correct, but in the function (stuff_atts), IF I leave 'value there, it throws an error.
Try it on Lisp from Message 3. Wierd. So, that's why I suggested changing it to 'value1 instead.
That goes OK.
Next, we need to know if he's just wanting to bump up the "01of04", to be "01of05" or such.
Then, we can do the (strcat of the drawing name...
ECCAD
Eccad, Yes my goal is to allow the user to enter the page number of the latest drawing. For example if the latest page is 5 then all the drawings in the folder would be renumbered with the latest page number. (1 of 5, 2 of 5, 3 of 5 ect...
Here's a screen print of the flow occurring in the lisps, It seems after the first interaction of the PageMe.lsp it encounters an error in the CPNNCA.lsp.
stuff_atts function fails because of this one additional princ statement right after the the if statement.
(if ss
(princ (strcat "\nPageme4"))
(prognSo when that princ function is removed then the progn will execute:
(defun stuff_atts ( BLKNAME )
(setq ss (ssget "X" (list (cons 2 BLKNAME)(cons 0 "INSERT"))))
(princ (strcat "\nPageme3"))
(if ss
;(princ (strcat "\nPageme4"))
(progn
(setq blk (vlax-ename->vla-object (ssname ss 0)))
(princ (strcat "\nPageme5"))
(setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))
(princ (strcat "\nPageme6"))
(foreach att atts
;(princ (strcat "\nPageme6a"))
(setq Tag (vla-get-tagstring att))
(princ (strcat "\nPageme7"))
(if (and (/= VALUE "") (= Tag TAGNAME))
(progn
;(princ (strcat "\nValue" value))
;(princ (strcat "\nTag" Tag))
(vla-put-textstring att VALUE)
)
)
)
)
)
)
Hmm.
Existing Attributes have values with a series, 'PAGE 1 OF 4, 'PAGE 2 OF 4, 'PAGE 3 OF 4, 'PAGE 4 OF 4 ..
If OP types in "1 OF 5", then (all) drawings will have 1 OF 5 placed in Attribute 'PAGE_X_OF_X', both sides.
So, if OP wants to just change the of 4 to be of 5, then just typing in "5" for max_page would change
those attributes (all) to be just "5", disgarding the original PAGE 1 OF 4'..
So, we will need to adjust the value1 by getting the original string (e.g. "PAGE 1 OF 4") and changing
that value1 to be: (setq value1 (strcat (substr (vla-get-textstring att) 1 10) value1))
assuming that they have similar existing values...
ECCAD
Good catch, I just replaced the whole function in my test, didn't see that one.
![]()
ECCAD
eccad, I made the change you suggested above.
(defun C:PAGEME ( max_page )
(princ (strcat "\nPageme1"))
(vl-load-com)
(setq BLKNAME "CDSTR1")
(setq TAGNAME "PAGE_X_OF_X")
; (setq VALUE1 max_page)
(setq value1 (strcat (substr (vla-get-textstring att) 1 10) value1))
(princ (strcat "\nPageme2"))
I may have miss something. I'm getting this now.
That error message comes from the (only) error trap active in CPNNCA.lsp,
So, if error occurs in Pageme.lsp, it falls back to the error trap.
The issue is in Pageme.lsp.
Question.
Do you want to 'get' the largest sheet # from the folder, or enter it ?
Lot easier to rely on OP to just check the stack, and enter it..
Harder, but possible to get 'last' sheet# from the drawing names.
Makes the assumption that the "05" would be the last 2 characters (less the .dwg).
Here's a modified version of Pageme.lsp that seems to work as expected.
ECCAD
Those changes should be (within) the Stuff_atts, not at that location..
See the attached pageme.lsp
ECCAD
It seems to be working! And to answer your question the user will enter the maximum page number in the dialog box.
Thank you for your help!
It seems to be working! And to answer your question the user will enter the maximum page number in the dialog box.
Thank you for your help!
On a side note,
I have tried to use the Visual Lisp Editor to step through the code but I can't seem to get it to work correctly. Is there a tutorial on it use?
autodesk has stopped further support on VLIDE but has moved to VS Code:
Can't find what you're looking for? Ask the community or share your knowledge.