TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: pedroantonio on March 02, 2014, 03:58:21 AM

Title: little help with pointsin.lsp
Post by: pedroantonio on March 02, 2014, 03:58:21 AM
I found this lisp for insert points into autocad.I change only the layer names. (attach file)

I want  to do a change in this code but i dont know how .. I want to add this two lines
Code - Auto/Visual Lisp: [Select]
  1. (setq scl (getvar "useri1"))
  2. (setq ht(* 0.0025 scl))

scl = scale  ,ht = text height
This two lines call a general lisp that change the size of all insert block in the drawing.
Sorry for my bad english. Please help ... Thanks
Title: Re: little help with pointsin.lsp
Post by: DEVITG on March 02, 2014, 08:15:59 PM
Pedro , me atrevo escribirte en castellano , que me imagino que es tu idioma nativo.

¿Donde quieres agregar las líneas ?

Para leer la variable  USERI1 , primero debes asignarle un valor

(setvar 'USERI1   45)

USERI1 a USERI5 admite enteros 23 , 567  890  etc y tiene la ventaja de que se guarda en el DWG

si quieres puedes conectarte a mi correo,  es mi nombre de usuario en gmail
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 03, 2014, 02:34:39 AM
Hello Devitg.Please write in english because i canot understand you !!!!!
this is the user1 lisp  i use for all my lisp
Code - Auto/Visual Lisp: [Select]
  1. ( DEFUN C:SETSC ()
  2.     (SETQ CURSC (getvar "useri1" ))
  3.     (princ "scale 1:")(princ cursc)
  4.     (setq newsc (getint "\nNew scale  1:"))
  5.     (setvar "useri1" newsc)
  6.       (setq a1 (getvar "useri1"))
  7.      (setvar "ltscale" (* a1 0.005))
  8.     (princ "\nThe drawing scale is 1:")(princ newsc)(princ)
  9. )

Then i add to all lisp i use  this code lines

Code - Auto/Visual Lisp: [Select]
  1. (setq scl (getvar "useri1"))
  2. (setq ht(* 0.0025 scl))

But in pointsin.lsp code i am confused. Can you help me ?

Thank you ..
Title: Re: little help with pointsin.lsp
Post by: irneb on March 03, 2014, 04:20:38 AM
First, the useri# sysvar only stores integers, not fractions. You might want to change that to userr1 instead so you can have scales of non integer values.

Second, if you want the text height adjusted for the scale ... then reading that LSP file it seems it uses DimScale x DimText to calculate the height. So either set a special DimStyle as current with the text height as you want it, or search through that list to use your calculation instead of where it uses getvar to get these 2 variables.
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 05, 2014, 10:21:03 AM
if i understand all the problem is only is this lines ?

Code - Auto/Visual Lisp: [Select]
  1.    PI:INSERTPOINTBLOCKS
  2.    (POINTSLIST POINTFORMAT / AROLD POINTBLOCKLAYERFORMAT)
  3.   (SETQ POINTBLOCKLAYERFORMAT (PI:GETBLOCKLAYERFORMAT POINTFORMAT))
  4.   (COMMAND "._undo" "_group")
  5.   (SETQ AROLD (GETVAR "attreq"))
  6.   (SETVAR "attreq" 0)
  7.   ;;Insert a Softdesk style block
  8.      ;; The format of pointlist is defined in GETPOINTSLIST
  9.      POINTLIST POINTSLIST
  10.     (PI:INSERTPOINTBLOCK
  11.       POINTLIST
  12.       POINTFORMAT
  13.       POINTBLOCKLAYERFORMAT
  14.     )
  15.   )
  16.   (SETVAR "attreq" AROLD)
  17.   (COMMAND "._undo" "_end")
  18. )
  19.  
  20.    PI:INSERTPOINTBLOCK (POINTLIST POINTFORMAT POINTBLOCKLAYERFORMAT / AT
  21.                         AV EL EN ET N
  22.                        )
  23.   (PI:MAKELAYER POINTBLOCKLAYERFORMAT POINTLIST POINTFORMAT)
  24.     "._insert"
  25.     "point"
  26.     ;; Chop off the z coordinate for 2D block insertion as advertised.
  27.     (REVERSE (CDR (REVERSE (CAR POINTLIST))))
  28.     (* (GETVAR "dimscale") (GETVAR "dimtxt"))
  29.     ""
  30.     0
  31.   )
  32.   (SETQ EN (ENTLAST))
Title: Re: little help with pointsin.lsp
Post by: irneb on March 06, 2014, 12:27:49 AM
Yes, that (* (getvar "dimscale") (getvar "dimtext")) gets those sysvars, multiplies them together and then passes the reult back to the surrounding form. In this case the command call at the position where it expects the block's scale factor.
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 06, 2014, 02:58:23 AM
i change the code to this
Code - Auto/Visual Lisp: [Select]
  1.    PI:INSERTPOINTBLOCKS
  2.    (POINTSLIST POINTFORMAT / AROLD POINTBLOCKLAYERFORMAT)
  3.   (SETQ POINTBLOCKLAYERFORMAT (PI:GETBLOCKLAYERFORMAT POINTFORMAT))
  4.   (COMMAND "._undo" "_group")
  5.   (SETQ AROLD (GETVAR "attdia"))
  6.   (SETVAR "attdia" 0)
  7.   ;;Insert a Softdesk style block
  8.      ;; The format of pointlist is defined in GETPOINTSLIST
  9.      POINTLIST POINTSLIST
  10.     (PI:INSERTPOINTBLOCK
  11.       POINTLIST
  12.       POINTFORMAT
  13.       POINTBLOCKLAYERFORMAT
  14.     )
  15.   )
  16.   (SETQ SCL (GETVAR "useri1"))
  17.   (SETQ SCL1 (* SCL 0.0025))
  18.   (SETVAR "attdia" 1)
  19.   (COMMAND "._undo" "_end")
  20. )
  21.  
  22.    PI:INSERTPOINTBLOCK (POINTLIST POINTFORMAT POINTBLOCKLAYERFORMAT / AT
  23.                         AV EL EN ET N DT1 SCL1 SCL1
  24.                        )
  25.   (PI:MAKELAYER POINTBLOCKLAYERFORMAT POINTLIST POINTFORMAT)
  26.   (COMMAND "._insert" "point" DT1 SCL1 SCL1 "0")
  27.   (SETVAR "attdia" 0)
  28. )
  29. (SETQ EN (ENTLAST))

But i have this error

Trapped error: no function definition: PI:GETDNPATH*Cancel*

I dont know  :embarrassed:
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 07, 2014, 10:12:50 AM
Any ideas ?
Title: Re: little help with pointsin.lsp
Post by: Kerry on March 07, 2014, 05:06:23 PM
Yes,
http://autocad.wikia.com/wiki/Attribute_Importer_(AutoLISP_application) (http://autocad.wikia.com/wiki/Attribute_Importer_(AutoLISP_application))

Do you have access to Google ?
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 07, 2014, 05:13:36 PM
Hi Kerry this is a dead link !!!
Title: Re: little help with pointsin.lsp
Post by: Kerry on March 07, 2014, 05:20:36 PM
The closing parenthesis should be in the link.

Fixed.
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 07, 2014, 05:35:36 PM
Kerry is using exactly the same code that I am trying to change
(* (GETVAR "dimscale") (GETVAR "dimtxt"))
This link does not help at all.
Can you help?

Thanks
Title: Re: little help with pointsin.lsp
Post by: Kerry on March 07, 2014, 05:44:00 PM
What do you want to change.
What do you want it to change to.


Only post the relevant code.

Consider this an exercise in asking the right question.
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 07, 2014, 05:57:46 PM
in *.mnl file i have ths lisp

Code - Auto/Visual Lisp: [Select]
  1. ( DEFUN C:SETSC ()
  2.     (SETQ CURSC (getvar "useri1" ))
  3.     (princ "scale 1:")(princ cursc)
  4.     (setq newsc (getint "\nNew scale  1:"))
  5.     (setvar "useri1" newsc)
  6.       (setq a1 (getvar "useri1"))
  7.      (setvar "ltscale" (* a1 0.005))
  8.     (princ "\nThe drawing scale is 1:")(princ newsc)(princ)
  9. )

for  giving the correct scale to my blocks,texts, everything

I change all the lisp roots i need to work with this lisp

for example i add this lines to the code
Code - Auto/Visual Lisp: [Select]
  1. (setq scl (getvar "useri1"))
  2. (setq ht(* 0.0025 scl))

I try to do the same thing with the pointsin.lsp  (I attach it in the beginning)

In my opinion, the problem focuses on these lines of code

Code - Auto/Visual Lisp: [Select]
  1.    PI:INSERTPOINTBLOCKS
  2.    (POINTSLIST POINTFORMAT / AROLD POINTBLOCKLAYERFORMAT)
  3.   (SETQ POINTBLOCKLAYERFORMAT (PI:GETBLOCKLAYERFORMAT POINTFORMAT))
  4.   (COMMAND "._undo" "_group")
  5.   (SETQ AROLD (GETVAR "attreq"))
  6.   (SETVAR "attreq" 0)
  7.   ;;Insert a Softdesk style block
  8.      ;; The format of pointlist is defined in GETPOINTSLIST
  9.      POINTLIST POINTSLIST
  10.     (PI:INSERTPOINTBLOCK
  11.       POINTLIST
  12.       POINTFORMAT
  13.       POINTBLOCKLAYERFORMAT
  14.     )
  15.   )
  16.   (SETVAR "attreq" AROLD)
  17.   (COMMAND "._undo" "_end")
  18. )
  19.  
  20.    PI:INSERTPOINTBLOCK (POINTLIST POINTFORMAT POINTBLOCKLAYERFORMAT / AT
  21.                         AV EL EN ET N
  22.                        )
  23.   (PI:MAKELAYER POINTBLOCKLAYERFORMAT POINTLIST POINTFORMAT)
  24.     "._insert"
  25.     "point"
  26.     ;; Chop off the z coordinate for 2D block insertion as advertised.
  27.     (REVERSE (CDR (REVERSE (CAR POINTLIST))))
  28.     (* (GETVAR "dimscale") (GETVAR "dimtxt"))
  29.     ""
  30.     0
  31.   )
  32.   (SETQ EN (ENTLAST))

I tried to change the code and I did these changes

Code - Auto/Visual Lisp: [Select]
  1.    PI:INSERTPOINTBLOCKS
  2.    (POINTSLIST POINTFORMAT / AROLD POINTBLOCKLAYERFORMAT)
  3.   (SETQ POINTBLOCKLAYERFORMAT (PI:GETBLOCKLAYERFORMAT POINTFORMAT))
  4.   (COMMAND "._undo" "_group")
  5.   (SETQ AROLD (GETVAR "attdia"))
  6.   (SETVAR "attdia" 0)
  7.   ;;Insert a Softdesk style block
  8.      ;; The format of pointlist is defined in GETPOINTSLIST
  9.      POINTLIST POINTSLIST
  10.     (PI:INSERTPOINTBLOCK
  11.       POINTLIST
  12.       POINTFORMAT
  13.       POINTBLOCKLAYERFORMAT
  14.     )
  15.   )
  16.   (SETQ SCL (GETVAR "useri1"))
  17.   (SETQ SCL1 (* SCL 0.0025))
  18.   (SETVAR "attdia" 1)
  19.   (COMMAND "._undo" "_end")
  20. )
  21.  
  22.    PI:INSERTPOINTBLOCK (POINTLIST POINTFORMAT POINTBLOCKLAYERFORMAT / AT
  23.                         AV EL EN ET N DT1 SCL1 SCL1
  24.                        )
  25.   (PI:MAKELAYER POINTBLOCKLAYERFORMAT POINTLIST POINTFORMAT)
  26.   (COMMAND "._insert" "point" DT1 SCL1 SCL1 "0")
  27.   (SETVAR "attdia" 0)
  28. )
  29. (SETQ EN (ENTLAST))

But i have this error

Trapped error: no function definition: PI:GETDNPATH*Cancel*

Can you help me ?

Thank you
Title: Re: little help with pointsin.lsp
Post by: Kerry on March 07, 2014, 06:02:53 PM

I have posted a link to that function, which you indicated was exactly the code you had
Find  WIKI-AI:GETDNPATH at the link I posted.
Title: Re: little help with pointsin.lsp
Post by: Kerry on March 07, 2014, 06:08:55 PM
In your modified code you are calling PI:INSERTPOINTBLOCK, passing value SCL1

SCL1 is defined after you call  PI:INSERTPOINTBLOCK ; it should be defined before, otherwise wou will pass nil as a parameter value.

No wait,
SCL1 is a global variable defined after you are using it.
Title: Re: little help with pointsin.lsp
Post by: pedroantonio on March 08, 2014, 11:00:25 AM
i am confused !!! :embarrassed:
Title: Re: little help with pointsin.lsp
Post by: Kerry on March 08, 2014, 11:14:12 AM
You woke me up at 2:00 am on Sunday morning to tell me that ??
Title: Re: little help with pointsin.lsp
Post by: MP on March 08, 2014, 11:17:35 AM
<blink> What the ... When did you guys become an item?