Jump to content

Recommended Posts

Posted

I am looking for a routine to automate what we already do. We have a routine that currently when we run the command it ask for "Select location on pipe" which then user selects a point where they want the leader to start.

 

After selecting the initial point the user then selects the "landing" point- the point where the number on a specific layer will appear.

 

It then asks the user to enter the number for point they are referencing. Once the user hits "1" then "enter". It automatically puts in that number on the layer specified in the code with a prefix(#) and a suffix (-). This gets the job done..

 

However, I am curious to see if there is a way we can automate the numbering some way so that maybe when the user starts the command it prompts [specify Starting Reference Point Number] so if the user wants to start with #44, he/she enters #44 then can begin putting in these points and it populate the numbers automatically instead of the user having to RERUN the command separately, having to specify the number then hit enter everytime.

 

Basically identical to Lee Macs Incremental Numbering Suite but with the option to pull leaders. Just seeing if there is anything out there I can use?

 

Thanks in advance.

Posted

What you want can be done with a lisp, an improvement on what you asked for is that you check the leaders 1st and get the last number and ask if to start from there. Here is an example of a Bubble routine with the twist of supporting Alpha or numbers.

 

; bubble pt num
; BY ALAN H AUG 2014
(defun make_circle ()
 (entmake (list (cons 0 "CIRCLE")
 (cons 8 "0")
 (cons 10 (list 0 0 0))
 (cons 40 3.25)  ; rad
 (cons 210 (list 0 0 1))
 (cons 62 256)
 (cons 39 0)
 (cons 6 "BYLAYER")
  )
 )
)     ; DEFUN
(defun make_sq ()
 (setq vertexList
 (list
 (list -3.25 -3.25 0.)
 (list 3.25 -3.25 0.)
 (list 3.25 3.25 0.)
 (list -3.25 3.25 0.)
 ))
 (entmake
   (append 
   (list '(0 . "LWPOLYLINE")
   '(100 . "AcDbEntity")
   '(100 . "AcDbPolyline")
   (cons 90 (length vertexList))
   (cons 70 1)   ; 1 closed : 0 open
   (cons 8 "0")
   (cons 38 0.0)
   (cons 210 (list 0.0 0.0 1.0))
   )
   (mapcar '(lambda (pt) (cons 10 pt)) vertexList)
   )
 )
)     ; defun
(defun Make_bubble ( )
 (entmake (list (cons 0 "BLOCK")
   (cons 2 Blkname)
   (cons 70 2)
   (cons 10 (list 0 0 0))
   (CONS 8 "0")
 ))
 (if (= resp "C")
 (make_circle)
 (make_sq)
 )
 (entmake (list (cons 0 "ATTDEF")
      (cons 8 "0")
      (cons 10 (list 0 0 0))
      (cons 1 "1")  ; default value
      (cons 2 blkname)  ; nblock name
      (cons 3 "Ptnum")  ; tag name
      (cons 6 "BYLAYER")
      (cons 7 "STANDARD") ;text style
      (cons 8 "0")  ; layer
      (cons 11 (list 0.0 0.0 0.0)) ; text insert pt
      (cons 39 0)
      (cons 40 3.5)  ; text height
      (cons 41 1)  ; X scale
      (cons 50 0)  ; Text rotation
      (cons 51 0)  ; Oblique angle
      (cons 62 256)  ; by layer color 
      (cons 70 0)
      (cons 71 0)  ;Text gen flag
      (cons 72 1)  ; Text Justify hor 1 center
      (cons 73 0)  ; field length
      (cons 74 2)  ; Text Justify ver 2 center
      (cons 210 (list 0 0 1))
 ))
 (entmake (list (cons 0 "ENDBLK")))
 (princ)

)
(defun C:bub (/ ptnum ptnumb pt pt2 oldsnap chrnum sc curspace)
 (if (= 1 (getvar 'cvport))
 (setq sc 1.0)
 (setq sc (/ 1000.0 (getreal "\nEnter plotting scale")))
 )
 (setq oldsnap (getvar "osmode"))
 (setvar "textstyle" "standard")
 (setq ptnum (getstring "\nEnter Pt Number or alpha"))
 (setq chrnum (ascii (substr ptnum 1 1))) ; 1st character is number
 (if (< chrnum 58)
 (setq ptnumb (atof ptnum))  ;convert back to a number 
 )

 (while (setq pt (getpoint "\Pick end of line Enter to exit"))
   (setq pt2 (polar pt (/ pi 2.0) 3.25))
   (setvar "osmode" 0)
   (if (< chrnum 58)
     (progn
(command "-insert"
  blkname
  pt
  sc
  ""
  0
  (rtos ptnumb 2 0)
)
(setq ptnumb (+ ptnumb 1))
     )
     (progn
(command "-insert"
  blkname
  pt
  sc
  ""
  0
  (chr chrnum)
)
(setq chrnum (+ chrnum 1))
     )
   )
   (command "move" "L" "" pt pt2)
   (setvar "osmode" 1)
 )
 (setvar "osmode" oldsnap)
 (princ)
)     ; end defun
;;;;;; 
    ; program starts here checking 
(alert "Type Bub to repeat\nYou can do alpha's or numbers\nSquare or circles")
(initget 6 "S s C c")
(setq resp (strcase
     (Getkword "\nDo you want Circle or Square C or S <C> ")
   )
)
(if (or (= resp "C") (= resp nil))
 (setq blkname "SETOUT_POINT_NO")
 (setq blkname "SETOUT_POINT_NOSQ")
)

(if (/= (tblsearch "BLOCK" blkname) NIL)
(PRINC "FOUND")    ; block exists
(Make_bubble)
)
(C:BUB)
(princ)

Posted

I know this wont make much sense because there are other pieces that this code refers to but its really just data that its referring to and coordinates that draw a solid arrow with a line to become the leader. I am able to get the actual code to loop, however I am still having to type the numbers manually. Im stumped and I know I am so close to getting it. Let me know what you think...

 

(defun c:DTEST (/ *error* oldlayr p1 p2 dpnum oldos)
(defun *error* (msg)
   (if oldlayr (setvar "clayer" oldlayr))
   (if oldos (setvar "osmode" oldos))
   (if msg (prompt msg))
   (princ)
 )
(WHILE
(setq oldos (getvar "osmode"))
(setq oldlayr (getvar "clayer")) (command "._-layer" "s" DATAPOINT "")
(initget 1)  (setq p1 (getpoint "\nSelect datapoint location on pipe: "))
(setvar "osmode" 0)
(initget 33) (setq p2 (getpoint p1 "\nSelect datapoint label location: "))
(if (= etype "G")     ;;;; This refers to whether our equipment is a certain type.
 (setq dpnum (strcase (getstring "\nEnter datapoint ID (A1 - A999) or (A1 - AZ99): ")))
 (setq dpnum (getreal "\nEnter datapoint number (1.00-999.99): ")))
(get_info  "DATAPOINTS" "END DATAPOINTS" DPINFO "#" "-0.00")   ;;;;;;;This just  simply looks at a .DAT file we refer to for Specific Data to be input  automatically into drawing.
(command "._-layer" "s" oldlayr "")
(setvar "OSMODE" OLDOS) 
) :end while
(*error* nil)
(prin1))

 

Im so close to getting it. I just need it to remember the number that was entered here:

 

  (setq dpnum (getreal "\nEnter datapoint number (1.00-999.99): ")))

 

...and add 1 every time it runs, so it automatically increments +1 from whatever the previous number was. I may be overthinking too much. We are quite busy around here.

 

Any HELP is tremendously appreciated.

 

Tyler

Posted

(get_info  "DATAPOINTS" "END DATAPOINTS" DPINFO "#" "-0.00")

 

This puts "#" as the prefix of the number and "-" as the suffix of the number

Posted (edited)

This is un tested

 

; change this line (setq dpnum (getreal "\nEnter datapoint number (1.00-999.99): "))
(getdpnum)

;add this above (While

(defun getdpnum ( )
(if (= dpnum nil)
(setq dpnum (getreal "\nEnter datapoint number (1.00-999.99): "))
(setq dpnum (+ dpnum 1))
)

Edited by BIGAL
Posted

Hey I am in the office this morning and am testing the updated pieces of code. Thank you so much by the way for chiming in! I really appreciate it. Although, I am still very new to lisp and programming I can somewhat navigate my way around it. However, I am getting the ole Error: Malformed list on input. If you find time today to assist, I would greatly appreciate it. In the meantime I will continue to evaluate. Hope to hear from you soon.

 

(defun c:DTEST (/ *error* oldlayr p1 p2 dpnum oldos)
(defun *error* (msg)
   (if oldlayr (setvar "clayer" oldlayr))
   (if oldos (setvar "osmode" oldos))
   (if msg (prompt msg))
   (princ)
   )
(defun getdpnum ()
(if (= dpnum nil)
(setq dpnum (getreal "\nEnter datapoint number (1.00-999.99): ")))
(setq dpnum (+ dpnum 1))
)
(WHILE
(setq oldos (getvar "osmode"))
(setq oldlayr (getvar "clayer")) (command "._-layer" "s" DATAPOINT "")
(initget 1)  (setq p1 (getpoint "\nSelect datapoint location on pipe: "))
(setvar "osmode" 0)
(initget 33) (setq p2 (getpoint p1 "\nSelect datapoint label location: "))
(if (= etype "G")
 (setq dpnum (strcase (getstring "\nEnter datapoint ID (A1 - A999) or (A1 - AZ99): ")))
(getdpnum)
(get_info "DATAPOINTS" "END DATAPOINTS" DPINFO "#" "-0.00")
(command "._-layer" "s" oldlayr "")
(setvar "OSMODE" OLDOS)
)
(*error* nil)
(prin1))

Posted

Even though it was error malformed list on input, I just noticed when I ran DTEST from the command line.. It prompted "Enter datapoint number (1.00-999.99):" but when I entered 1 it just showed "2" at the command line, I must have something in the wrong place.

Posted

This is basically what the code is used for... We run it to create data labels for specific points.

 

Capture.jpg

Posted

Hey BIGAL, I evaluated the code earlier today and deleted a redundancy, I believe thats what was messing up the entire routine. Just wanted to send and update to let you know if your reading this, I was able to get it.

 

Only small issue I am seeing now is a piece im going to have to look at tomorrow is that after user selects location and the code prompts for datapoint, when the user enters just say 1, it actually enters the number 2 in cad then loops and increments from there.

 

Again thanks for chiming in! Hope all is well. Merry Christmas!

Posted

Sorry had 3 right parenthis on dpnum should be two. Changed example above

Posted (edited)

setting a global variable http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-A8045F62-1CE3-4022-ACC1-CC0E2C1E158D than adding to it would work for a secession

what happens when you delete an entry will the numbers reset to new ones or remain without a particular numbered entry?

can they be renumbered or must they remain as written?

a local variable would only work for an instance once the lisp ran it would reset when run a 2nd time.

a global will retain so long as autocad is open once ran.

Edited by pattyandme
spellig error
  • 9 months later...
Posted

hello

coud you plzz give me complete corrected code?? dtest dont proper operate for me

Posted

Hello hosyn, how are you? I am not quite sure what exactly you are looking to use in this code? If it is just leader automation then I am sure someone here can chime in and help you, however. This code was written to work together with a myriad of other routines we have loaded that create drawing specific layers. It also includes some parts that extract data from excel and MS Access and put into a .DAT file for reference(DPINFO). Those are specific to my company and the data we use. Lots of tables and stuff. Unless you had every single file we use and the same information we use then this wouldn't work for you. Can you post a few details about what your looking for?

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