Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Having issues with this lisp development

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
Markeckert
713 Views, 25 Replies

Having issues with this lisp development

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?

25 REPLIES 25
Message 2 of 26
Moshe-A
in reply to: Markeckert

@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

 

Message 3 of 26
Markeckert
in reply to: Moshe-A

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? 

Message 4 of 26
ec-cad
in reply to: Markeckert

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 ?

 

 

Message 5 of 26
paullimapa
in reply to: ec-cad

Aactually no such system variable as value so (getvar"value") will return nil.

@Markeckert What exactly are you trying to retrieve?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 26
ec-cad
in reply to: paullimapa

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

Message 7 of 26
paullimapa
in reply to: ec-cad

exactly...if we assume that the value is his variable set here:

(setq VALUE max_page)
to retrieve this he should not be using:
(getvar "value")
but instead just show it as value:

 

(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?

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 8 of 26
ec-cad
in reply to: Markeckert

Here's the CPNNCA.lsp, with the line:

(setq sh (vla-getInterfaceObject (vlax-get-acad-object)))

removed. It works now.

 

ECCAD

Message 9 of 26
paullimapa
in reply to: ec-cad

that's kind of like @Moshe-A reply earlier...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 10 of 26
ec-cad
in reply to: paullimapa

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

 

Message 11 of 26
Markeckert
in reply to: Markeckert

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.

Markeckert_1-1735328319456.png

 

Message 12 of 26
paullimapa
in reply to: ec-cad

stuff_atts function fails because of this one additional princ statement right after the the if statement. 

    (if ss
(princ (strcat "\nPageme4"))
      (progn

 So 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)
            )
          )
        )
      )
    )
  )

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 13 of 26
ec-cad
in reply to: ec-cad

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

 

Message 14 of 26
ec-cad
in reply to: paullimapa

Good catch, I just replaced the whole function in my test, didn't see that one.

:slightly_smiling_face:

ECCAD

Message 15 of 26
Markeckert
in reply to: Markeckert

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.

Markeckert_0-1735329593486.png

 

Message 16 of 26
ec-cad
in reply to: Markeckert

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

 

 

Message 17 of 26
ec-cad
in reply to: Markeckert

Those changes should be (within) the Stuff_atts, not at that location..

See the attached pageme.lsp

 

ECCAD

Message 18 of 26
Markeckert
in reply to: Markeckert

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!

Message 19 of 26
Markeckert
in reply to: ec-cad

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? 

Message 20 of 26
paullimapa
in reply to: Markeckert

autodesk has stopped further support on VLIDE but has moved to VS Code:

AutoCAD 2023 Developer and ObjectARX Ayuda | Getting Started with Visual Studio Code (AutoLISP/VS Co...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report