Jump to content

Lisp to insert positional number


Tiger

Recommended Posts

Hi guys,

 

I'm wondering if someone has a lisp in store that looks like the image I've attached. it's basically a line with an attached circle and a number inserted in the centre of the circle. So I want to be able to pick the end of the line and then where I want the number to be and what number add. Anyone got something like that that I can fiddle with?

 

Thanks in advance :)

Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • Tiger

    14

  • NBC

    9

  • Lee Mac

    8

  • lpseifert

    2

Top Posters In This Topic

Posted Images

Hi Tiger,

 

I have a LISP for working with Tank Instrument Tagging, which can insert any number of tags, accounting for the scale of the drawing, and all variables can be customised to suit your needs:

 


;    .: Nozzle & Equipment Tags :.
;
;        .: by Lee McDonnell :.


(defun c:tktag2 (/ oldlay oldorth oldsnap dwgscal tagpt tagline linent linend tagang cnt tcirc tagcnt tagtxt tcirccent)
   (princ "\nInitialising...")
   (if    (not (getenv "tag:tsize"))
       (setenv "tag:tsize" (rtos (getvar "TEXTSIZE")))
   ) ; end if
   (if     (not (getenv "tag:tcircr"))
       (setenv "tag:tcircr" "4.2")
   ) ; end if
   (princ
       (strcat    "\nType \"TKTAG2SET\" to Change Base Variables  --  Current Settings:"
           "\n\tText Height: "
           (getenv "tag:tsize")
           ",\tText Circle Radius @ 1:1: "
           (getenv "tag:tcircr")
       ) ; end strcat
   ) ; end princ

   (defun *error*(msg)
   (setq varLst    (list "CMDECHO" "OSMODE" "CLAYER" "DIMSCALE")
         oldVars    (mapcar 'getvar varLst)
   ); end setq 
   (if oldVars
       (mapcar 'setvar varLst oldVars)
   ); end if
   (princ "\nError Or Esc Pressed... ")
   (princ)
   ); end of *error*
       
   (setq oldlay (getvar "clayer"))
   (setq oldorth (getvar "orthomode"))
   (setq oldsnap (getvar "osmode"))
   (setvar "cmdecho" 0)
   (mapcar 'CreateLayer '("1" "2" "3" "4" "5"))
   (if
       (/= (setq dwgscal (getreal "\nType Drawing Scale: 1:")) nil)
       (progn
           (while
               (/= (setq tagpt (getpoint "\nSelect First Tag Point: ")) nil)
               (setvar "clayer" "5")
               (setvar "orthomode" 1)
               (prompt "\nSelect Second Tag Point: ")
               (command "_line"
                   tagpt
                   pause ""
               ) ; end line
               (setq tagline (entlast))
               (setq linent (entget tagline))
               (setq linend (cdr (assoc 11 linent)))
               (setq tagang (angle tagpt linend))
               (setq cnt 1)
               (setq tcirc (* dwgscal (atof (getenv "tag:tcircr"))))
               (if
                   (and    (setq tagcnt (getint "\nSpecify Number of Tags: "))
                       (/= tagcnt nil)
                   ) ; end and
                   (progn
                       (while
                           (and
                               (<= cnt tagcnt)
                               (/= (setq tagtxt (getstring (strcat 
                                               "\nType Text for Tag ["
                                               (rtos cnt 2 0)
                                               "]: "))) "")
                           ) ; end and
                           (setq tagtxt (strcase tagtxt))
                           (setvar "clayer" "TEXT")
                           (setq tcirccent
                               (polar
                                   linend
                                   tagang
                                   (* (- (* cnt 2) 1) tcirc)
                               ) ; end polar
                           ) ; end setq
                           (setvar "osmode" 0)
                           (command "_circle"
                               tcirccent
                               tcirc
                           ) ; end circle
                           (entmake
                               (list    '(0 . "TEXT")
                                   '(8 . "TEXT")
                                   (cons 10 tcirccent)
                                   (cons 40 (* dwgscal (atof (getenv "tag:tsize"))))
                                   (cons 1 tagtxt)
                                   '(50 . 0.0)
                                   '(7 . "STANDARD")
                                   '(71 . 0)
                                   '(72 . 1)
                                   '(73 . 2)
                                   (cons 11 tcirccent)
                               ) ; end list
                           ) ; end entmake
                           (setvar "osmode" oldsnap)
                           (setq cnt (+ cnt 1))
                           (setq tagtxt "")
                       ) ; end while
                   ) ; end progn
                   (alert "\tTag Number Must Be Greater Than \n\tOr Equal To One.")
               ) ; end if
           ) ; end while
       ) ; end progn
       (alert "\tDrawing Scale Must Be Greater Than \n\tOr Equal To One.")
   ) ; end if
   (setvar "clayer" oldlay)
   (setvar "orthomode" oldorth)
   (setvar "cmdecho" 1)
   (princ "\n\tFunction Complete.")
   (princ)
) ; end program

(defun CreateLayer (Name)
     (if
       (not (tblsearch "LAYER" Name))
            (command "_.-layer" "_m" Name "_c" Name Name "")
   ); end if
); end of  CreateLayer

; Base Variables

(defun c:tktag2set (/ tsize tcircr)
   (if    (not (getenv "tag:tsize"))
       (setenv "tag:tsize" (rtos (getvar "TEXTSIZE")))
   ) ; end if
   (if     (not (getenv "tag:tcircr"))
       (setenv "tag:tcircr" "4.2")
   ) ; end if
   (princ
       (strcat    "\nCurrent Settings:"
           "\n\tText Height: "
           (getenv "tag:tsize")
           ",\tText Circle Radius @ 1:1: "
           (getenv "tag:tcircr")
       ) ; end strcat
   ) ; end princ
   (if    (setq tsize (getreal (strcat
                   "\nSpecify Text Height <"
                   (getenv "tag:tsize")
                   ">: ")))
       (setenv "tag:tsize" (rtos tsize))
   ) ; end if
   (if    (setq tcircr (getreal (strcat
                   "\nSpecify Text Circle Radius @ 1:1 <"
                   (getenv "tag:tcircr")
                   ">: ")))
       (setenv "tag:tcircr" (rtos tcircr))
   ) ; end if
   (princ "\nBase Variables Set.")
   (princ)
) ; end program
   
               
                                

Hope this helps - let me know if you have any queries. :P

Link to comment
Share on other sites

When I insert it, I just get one grip point at the end of the arrow, can only move the whole thing?

Yes, I had trouble with the dynamic block.

Once you have inserted the dwg file into your drawing, you will need to explode it just the once; to have the functionality I described in my previous post.

Link to comment
Share on other sites

hey, Lee, thanks :) However, after I get this:

Type "TKTAG2SET" to Change Base Variables -- Current Settings:

Text Height: 5, Text Circle Radius @ 1:1: 7

Type Drawing Scale: 1:1

 

Select First Tag Point:

Error Or Esc Pressed...

Command:

 

:?

 

NBC - can't explode it...:?

Link to comment
Share on other sites

Hi Tiger,

 

Yeh, sorry about that - I didnt include a layer creator in the code as I always use a template:

 

Try this:

 

;    .: Nozzle & Equipment Tags :.
;
;        .: by Lee McDonnell :.


(defun c:tktag2 (/     *error* oldlay oldorth oldsnap dwgscal tagpt tagline linent linest
           linend tagang cnt tcirc tagcnt tagtxt tcirccent)

   (princ "\nInitialising...")
   (if    (not (getenv "tag:tsize"))
       (setenv "tag:tsize" (rtos (getvar "TEXTSIZE")))
   ) ; end if
   (if     (not (getenv "tag:tcircr"))
       (setenv "tag:tcircr" "4.2")
   ) ; end if
   (princ
       (strcat    "\nType \"TKTAG2SET\" to Change Base Variables  --  Current Settings:"
           "\n\tText Height: "
           (getenv "tag:tsize")
           ",\tText Circle Radius @ 1:1: "
           (getenv "tag:tcircr")
       ) ; end strcat
   ) ; end princ

   (defun *error*(msg)
   (setq varLst    (list "CMDECHO" "OSMODE" "CLAYER" "DIMSCALE")
         oldVars    (mapcar 'getvar varLst)
   ); end setq 
   (if oldVars
       (mapcar 'setvar varLst oldVars)
   ); end if
   (princ "\nError Or Esc Pressed... ")
   (princ)
   ); end of *error*
       
   (setq oldlay (getvar "clayer"))
   (setq oldorth (getvar "orthomode"))
   (setq oldsnap (getvar "osmode"))
   (setvar "cmdecho" 0)
   (if (not (tblsearch "LAYER" "TAGLINE"))
   (command "-layer" "m" "TAGLINE" "c" "5" "TAGLINE" ""))
   (if (not (tblsearch "LAYER" "TEXT"))
   (command "-layer" "m" "TEXT" "c" "2" "TEXT" ""))
   (if
       (/= (setq dwgscal (getreal "\nType Drawing Scale: 1:")) nil)
       (progn
           (setvar "clayer" "TAGLINE")
           (while
               (/= (setq tagpt (getpoint "\nSelect First Tag Point: ")) nil)
               (prompt "\nSpecify Other Tag Points: ")
               (command "_line" tagpt)
               (while (> (getvar 'CmdActive) 0) (command pause))
               (setq tagline (entlast))
               (setq linent (entget tagline))
               (setq linest (cdr (assoc 10 linent)))
               (setq linend (cdr (assoc 11 linent)))
               (setq tagang (angle linest linend))
               (setq cnt 1)
               (setq tcirc (* dwgscal (atof (getenv "tag:tcircr"))))
               (if
                   (and    (setq tagcnt (getint "\nSpecify Number of Tags: "))
                       (/= tagcnt nil)
                   ) ; end and
                   (progn
                       (while
                           (and
                               (<= cnt tagcnt)
                               (/= (setq tagtxt (getstring (strcat 
                                               "\nType Text for Tag ["
                                               (rtos cnt 2 0)
                                               "]: "))) "")
                           ) ; end and
                           (setq tagtxt (strcase tagtxt))
                           (setvar "clayer" "TEXT")
                           (setq tcirccent
                               (polar
                                   linend
                                   tagang
                                   (* (- (* cnt 2) 1) tcirc)
                               ) ; end polar
                           ) ; end setq
                           (setvar "osmode" 0)
                           (command "_circle"
                               tcirccent
                               tcirc
                           ) ; end circle
                           (entmake
                               (list    '(0 . "TEXT")
                                   '(8 . "TEXT")
                                   (cons 10 tcirccent)
                                   (cons 40 (* dwgscal (atof (getenv "tag:tsize"))))
                                   (cons 1 tagtxt)
                                   '(50 . 0.0)
                                   '(7 . "STANDARD")
                                   '(71 . 0)
                                   '(72 . 1)
                                   '(73 . 2)
                                   (cons 11 tcirccent)
                               ) ; end list
                           ) ; end entmake
                           (setvar "osmode" oldsnap)
                           (setq cnt (+ cnt 1))
                           (setq tagtxt "")
                       ) ; end while
                   ) ; end progn
                   (alert "\tTag Number Must Be Greater Than \n\tOr Equal To One.")
               ) ; end if
           ) ; end while
       ) ; end progn
       (alert "\tDrawing Scale Must Be Greater Than \n\tOr Equal To One.")
   ) ; end if
   (setvar "clayer" oldlay)
   (setvar "orthomode" oldorth)
   (setvar "cmdecho" 1)
   (princ "\n\tFunction Complete.")
   (princ)
) ; end program

; Base Variables

(defun c:tktag2set (/ tsize tcircr)
   (if    (not (getenv "tag:tsize"))
       (setenv "tag:tsize" (rtos (getvar "TEXTSIZE")))
   ) ; end if
   (if     (not (getenv "tag:tcircr"))
       (setenv "tag:tcircr" "4.2")
   ) ; end if
   (princ
       (strcat    "\nCurrent Settings:"
           "\n\tText Height: "
           (getenv "tag:tsize")
           ",\tText Circle Radius @ 1:1: "
           (getenv "tag:tcircr")
       ) ; end strcat
   ) ; end princ
   (if    (setq tsize (getreal (strcat
                   "\nSpecify Text Height <"
                   (getenv "tag:tsize")
                   ">: ")))
       (setenv "tag:tsize" (rtos tsize))
   ) ; end if
   (if    (setq tcircr (getreal (strcat
                   "\nSpecify Text Circle Radius @ 1:1 <"
                   (getenv "tag:tcircr")
                   ">: ")))
       (setenv "tag:tcircr" (rtos tcircr))
   ) ; end if
   (princ "\nBase Variables Set.")
   (princ)
) ; end program
   
               
                                   
                           

Link to comment
Share on other sites

Bedit, then explode :)

 

Come on now Tiger; must we do everything for you ?

 

Yep, that's what you're here for 8)

 

and no, can't get it to behvae like you described..I can get it down to the block det-leader1 but that I can't exlpode and I only have one grippoint

Link to comment
Share on other sites

BEDIT the block det-leader.

Then in the Properties diallogue box (with no entities selected); look for Allow Exploding, and then set it to Yes.

BSAVE, then BCLOSE.

you should now be able to explode the block.

Link to comment
Share on other sites

BEDIT the block det-leader.

Then in the Properties diallogue box (with no entities selected); look for Allow Exploding, and then set it to Yes.

BSAVE, then BCLOSE.

you should now be able to explode the block.

 

so yes, thanks, now I can explode the block. but if I do, I loose the attributed block functions....have I lost you somewhere NBC? Or did you loose me? :?

Link to comment
Share on other sites

I don't know !

Let me re-cap things.

1. Insert the uploaded dwg file into your drawing.

2. Explode the block you just inserted.

3. Click the block and drag the whole of the block (using the square located at the arrow end) into the required position.

4. Click the block and drag the Number/Circle (using the square located at the centre of the circle) into the required position.

5. Edit the attributes to show your desired number.

Link to comment
Share on other sites

I tried that LPS; but the leader line always 'defaults' to one of the circle quadrants, rather than radiating from the centre of the circle (and ending at the circles edge)

Link to comment
Share on other sites

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...