Jump to content

Recommended Posts

Posted

Hello peeps

 

just wondering if anyone can help, I have a block which is for setting out points, it simply gives the x and y coordinates which can be exported to an excel file to create a setting out table. My question is, is there a way to have an attribute within the block which will give a numerical reference to the block? for example when you inset the first setting out block it displays the number 1, then when you insert another it will display the number 2 etc etc.

 

Probably far to difficult but thought I would ask.

 

Any help would be great

 

Cheers

Posted

There is so many ways to do this, obvious way is add ptnum to block as an attribute, the auto what was last number is pretty easy you search via lisp the block attributes and find last number, then using lisp insert or label a point with correct ptnum. If you use dataextract it will produce a csv file ready to go. http://www.lee-mac.com has a real nice ptnumber routine that auto updates. We have make new, export all out, make a table list.

 

You should post a sample dwg with a few points.

 

Here is a example numbers in sq or circle as well as A-Z

 

; 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

many thanks al, im still totally lost with lisp, but I have however managed to use the action recorder to get a macro to do what I want, the only problem im having is getting the right text. here is what my macro does so far

 

insert a base block which has 3 d texts, one ref, one x vlaue and one y value

 

once instered at 0,0 it prompts for unser input to change the ref

 

once enter is pressed it then goes into model space and prompts the user to select the setting out point location whilst invoking the id command

 

once the user has selected the point the macro then goes back into paper space and selects the x value fron the id resaults and pastes it into the relevent dtext and then the same with the y.

 

thats basically it but I cant seem to get it to copy and paste the latest id information, when it is recording what I am doing I dont know howe to tell it to only copy the x and y results from the last id done?

 

Does that make any sense at all to you lol

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