Jump to content

Recommended Posts

Posted

See here:

 

(defun c:ty  (/ hOff vOff suff lay olddim pt) ; Define Function and Localise Variables

 (setq

[b][color=Red]    hoff 0.2 ; <<-- Horizontal Offset
   vOff 0.15 ; <<-- Vertical Offset
   suff "m" ; <<-- Suffix
   lay  "EPT" ; <<-- Layer (Text and Block)[/color][/b]

   ) ; End Setq

 (setq olddim (getvar "DIMZIN")) ; Store Old DIMZIN Variable

 (setvar "DIMZIN" 0) ; Set to not suppress Decimal Zeros

 (if (setq pt (getpoint "\nSelect Point: ")) ; If user Selects a Point...

   (progn ; Wrap the Fllowing Statements

     (SetBlkTF "ept") ; Call "SetBlkTF" sub-function

     (entmake ; Entmake the Block

       (list (cons 0 "INSERT") ; Object Type
             (cons 8 lay) ; Block Layer
             (cons 2 "ept") ; Block Name
             (cons 10 pt)))

     (Make_Text

       (polar (polar pt (/ pi 2) vOff) 0 hoff)

       (strcat

         (rtos

           (cadr pt)

           2

           2)

         suff)

       0.0

       lay)))

 (setvar "DIMZIN" olddim)

 (princ))

(defun Make_Text  (pt val rot lay)

 (entmake (list '(0 . "TEXT")
                (cons 8 lay) ; <<-- Layer (String)
                (cons 10 pt)
                (cons 40 2.5) ; <<-- Text Height (Real)
                (cons 1 val)
                (cons 50 (* pi (/ rot 180.)))
                (cons 7 (getvar "TEXTSTYLE"))
                '(71 . 0) ; 
                '(72 . 0) ; 0=left     1=center  2=right
                '(73 . 2) ; 0=baseline 1=bottom  2=middle  3=top
                (cons 11 pt))))

 ; FORCE BLOCK TABLE  (David Bethel)

(defun SetBlkTF  (n)
 (cond ((not (snvalid n))
        (princ "\nInvalid Block Name - " n)
        (exit))
       ((tblsearch "BLOCK" n))
       ((findfile (strcat n ".DWG"))
        (command "_.INSERT" n)
        (command))
       (T ; If all else fails....
        (entmake (list (cons 0 "BLOCK") (cons 2 n) (cons 10 (list 0 0 0)) (cons 70 0)))
        (entmake (list (cons 0 "TEXT")
                       (cons 1 (strcat "BLOCK PLACECARD - " n))
                       (cons 7 (cdr (assoc 2 (tblnext "STYLE" T))))
                       (cons 8 "0")
                       (cons 10 (list 0 0 0))
                       (cons 11 (list 0 0 0))
                       (cons 40 (max 1 (getvar "TEXTSIZE")))
                       (cons 72 4)))
        (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))))
 n)

  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

  • Rooster

    24

  • Lee Mac

    20

  • ronjonp

    3

  • fuccaro

    2

Top Posters In This Topic

Posted Images

Posted

ok - i run that & the block now goes into the layer i want, but my text isn't appearing at all. i get this msg:

 

Select Point: Error: bad argument type: stringp nil

Posted

Haha I cannot believe we are having this much trouble with such a simple LISP :P:P:P

Posted
Its seems to run fine for me :)

 

well i get the same error message each time..... i'm in a brand new drawing, with all the blocks/layers that i need etc. ????? any idea what exactly that error message might refer to?

Posted

Here's what I have - it's same as yours except for the highlighted changes:

(defun c:[b]ept[/b]  (/ hOff vOff lay olddim pt) ; Define Function and Localise Variables [b]suff variable removed as i'm not using it on this LISP[/b]

 (setq

   hoff 0.1 ; <<-- Horizontal Offset [b]offsets changed to my settings[/b]
   vOff 0.12 ; <<-- Vertical Offset
   lay  "ELEVATIONS" ; <<-- Layer (Text and Block)[b]changed to my layer name[/b]

   ) ; End Setq

 (setq olddim (getvar "DIMZIN")) ; Store Old DIMZIN Variable

 (setvar "DIMZIN" 0) ; Set to not suppress Decimal Zeros

 (if (setq pt (getpoint "\nSelect Point: ")) ; If user Selects a Point...

   (progn ; Wrap the Fllowing Statements

     (SetBlkTF "ept") ; Call "SetBlkTF" sub-function

     (entmake ; Entmake the Block

       (list (cons 0 "INSERT") ; Object Type
             (cons 8 lay) ; Block Layer
             (cons 2 "ept") ; Block Name
             (cons 10 pt)))

     (Make_Text

       (polar (polar pt (/ pi 2) vOff) 0 hoff)

       (strcat

         (rtos

           (cadr pt)

           2

           2)

         suff)

       0.0

       lay)))

 (setvar "DIMZIN" olddim)

 (princ))

(defun Make_Text  (pt val rot lay)

 (entmake (list '(0 . "TEXT")
                (cons 8 lay) ; <<-- Layer (String)
                (cons 10 pt)
                (cons 40 0.2) ; <<-- Text Height (Real)[b]text ht changed[/b]
                (cons 1 val)
                (cons 50 (* pi (/ rot 180.)))
                (cons 7 (getvar "TEXTSTYLE"))
                '(71 . 0) ; 
                '(72 . 0) ; 0=left     1=center  2=right
                '(73 . 2) ; 0=baseline 1=bottom  2=middle  3=top
                (cons 11 pt))))

 ; FORCE BLOCK TABLE  (David Bethel)

(defun SetBlkTF  (n)
 (cond ((not (snvalid n))
        (princ "\nInvalid Block Name - " n)
        (exit))
       ((tblsearch "BLOCK" n))
       ((findfile (strcat n ".DWG"))
        (command "_.INSERT" n)
        (command))
       (T ; If all else fails....
        (entmake (list (cons 0 "BLOCK") (cons 2 n) (cons 10 (list 0 0 0)) (cons 70 0)))
        (entmake (list (cons 0 "TEXT")
                       (cons 1 (strcat "BLOCK PLACECARD - " n))
                       (cons 7 (cdr (assoc 2 (tblnext "STYLE" T))))
                       (cons 8 "0")
                       (cons 10 (list 0 0 0))
                       (cons 11 (list 0 0 0))
                       (cons 40 (max 1 (getvar "TEXTSIZE")))
                       (cons 72 4)))
        (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))))
 n)

 

When I run your unchanged LISP it works as expected, but as far as I can see I've only changed little things, so I don't understand why it's having problems....

 

EDIT: ok, i think i've sorted it.... i had removed the suff variable on this LISP, but by leaving it in with the suff ="" (ie, no suff) it's working as i want it to!! :)

Posted

Its because the suff is missing:

 

(defun c:ept  (/ hOff vOff lay olddim pt) ; Define Function and Localise Variables suff variable removed as i'm not using it on this LISP

 (setq

   hoff 0.1 ; <<-- Horizontal Offset offsets changed to my settings
   vOff 0.12 ; <<-- Vertical Offset
   suff ""
   lay  "ELEVATIONS" ; <<-- Layer (Text and Block)changed to my layer name

   ) ; End Setq

 (setq olddim (getvar "DIMZIN")) ; Store Old DIMZIN Variable

 (setvar "DIMZIN" 0) ; Set to not suppress Decimal Zeros

 (if (setq pt (getpoint "\nSelect Point: ")) ; If user Selects a Point...

   (progn ; Wrap the Fllowing Statements

     (SetBlkTF "ept") ; Call "SetBlkTF" sub-function

     (entmake ; Entmake the Block

       (list (cons 0 "INSERT") ; Object Type
             (cons 8 lay) ; Block Layer
             (cons 2 "ept") ; Block Name
             (cons 10 pt)))

     (Make_Text

       (polar (polar pt (/ pi 2) vOff) 0 hoff)

       (strcat

         (rtos

           (cadr pt)

           2

           2)

         suff)

       0.0

       lay)))

 (setvar "DIMZIN" olddim)

 (princ))

(defun Make_Text  (pt val rot lay)

 (entmake (list '(0 . "TEXT")
                (cons 8 lay) ; <<-- Layer (String)
                (cons 10 pt)
                (cons 40 0.2) ; <<-- Text Height (Real)text ht changed
                (cons 1 val)
                (cons 50 (* pi (/ rot 180.)))
                (cons 7 (getvar "TEXTSTYLE"))
                '(71 . 0) ; 
                '(72 . 0) ; 0=left     1=center  2=right
                '(73 . 2) ; 0=baseline 1=bottom  2=middle  3=top
                (cons 11 pt))))

 ; FORCE BLOCK TABLE  (David Bethel)

(defun SetBlkTF  (n)
 (cond ((not (snvalid n))
        (princ "\nInvalid Block Name - " n)
        (exit))
       ((tblsearch "BLOCK" n))
       ((findfile (strcat n ".DWG"))
        (command "_.INSERT" n)
        (command))
       (T ; If all else fails....
        (entmake (list (cons 0 "BLOCK") (cons 2 n) (cons 10 (list 0 0 0)) (cons 70 0)))
        (entmake (list (cons 0 "TEXT")
                       (cons 1 (strcat "BLOCK PLACECARD - " n))
                       (cons 7 (cdr (assoc 2 (tblnext "STYLE" T))))
                       (cons 8 "0")
                       (cons 10 (list 0 0 0))
                       (cons 11 (list 0 0 0))
                       (cons 40 (max 1 (getvar "TEXTSIZE")))
                       (cons 72 4)))
        (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))))
 n)

Posted

thanks lee - i think that is all working now, at long last!!! thanks for all your help.....

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...