Lisp adjustments

Lisp adjustments

JB-T
Enthusiast Enthusiast
938 Views
4 Replies
Message 1 of 5

Lisp adjustments

JB-T
Enthusiast
Enthusiast

Hi,

 

I found this fine lsp that allows me to annotate elevation and insert a point at random pick points.

 

I have been using it for a couple of weeks now and I noticed a couple of things that I would like to modify.

 

 

First, how can I make this routine ask me, at the beginning, for the text height I want to use ?

 

Second, when I annotate random pick points, a point and an annotation is added for the elevation, but the annotation is only "###" until I exit the command. What is the problem?

 

Finally, I know there is a way to use a comma as decimal separator (vl-string-subst "," ".") but I don't know where to insert it in the code.

 

 

Thank you for taking the time to help me !

 

 

(defun C:zlb (/ acsp adoc mtx pt str util)
  (vl-load-com)
  (or adoc
      (setq adoc
	     (vla-get-activedocument
	       (vlax-get-acad-object)
	     )
      )
  )
  (if (and
	(= (getvar "tilemode") 0)
	(= (getvar "cvport") 1)
      )
    (setq acsp (vla-get-paperspace adoc))
    (setq acsp (vla-get-modelspace adoc))
  )
  (or util
      (setq util
	     (vla-get-utility adoc)
      )
  )

  (setvar "fieldeval" 31)			  ;to update field in all cases
  (setvar "fielddisplay" 0)			  ;without grey mask
  (setvar "pdsize" 0.1)				  ;point size, change by suit
  (setvar "pdmode" 34)				  ;point mode, change by suit  
  (while
    (or	(vla-initializeuserinput util 0 " ")
	(not
	  (vl-catch-all-error-p
	    (setq
	      pt (vl-catch-all-apply
		   (function
		     (lambda ()
		       (vla-getpoint
			 util
			 nil
			 "\nSpecify point (Or press Enter to exit) >>"
		       )
		     )
		   )
		 )
	    )
	  )
	)
    )
     (if pt
       (progn
	 (vla-addpoint acsp pt)
	 (setq mtx (vla-addmtext acsp pt 0.0 "###")) ;any string
         ;; architectural units : 
;;;	 (setq str
;;;		(strcat
;;;		  "%<\\AcObjProp Object(%<\\_ObjId "
;;;		  (itoa
;;;		    (vla-get-objectid
;;;		      mtx
;;;		    )
;;;		  )
;;;		  ">%).InsertionPoint \\f \"%lu4%pt4\">%"
;;;		)
;;;	 )
	 ;; decimal units : 
	 (setq str
		(strcat
		  "%<\\AcObjProp Object(%<\\_ObjId "
		  (itoa
		    (vla-get-objectid
		      mtx
		    )
		  )
		  ">%).InsertionPoint \\f \"%lu2%pt4\">%"
		)
	 )
	 (vla-put-textstring mtx str)
	 (vla-update mtx)
       )
     )
  )
  (vla-regen adoc acactiveviewport)
  (vl-catch-all-apply
    (function (lambda ()
		(vlax-release-object mtx)
	      )
    )
  )
  (princ)
)
(prompt "\n")
(prompt "\n\t###\tType ZLB to run point labeling\t###\n")

 

0 Likes
939 Views
4 Replies
Replies (4)
Message 2 of 5

krzysztof.psujek
Advocate
Advocate

Hi,

1. mtext created by routine uses system variable TEXTSIZE to set its size,

just change it before run lisp and you will get what you want.

 

add for example sth like this before setvars:

 

...

(if (setq txtsize (getreal "\nEnter text heigth: ")) (setvar 'textsize txtsize) )

(setvar "fieldeval" 31) ;to update field in all cases
(setvar "fielddisplay" 0) ;without grey mask
(setvar "pdsize" 0.1) ;point size, change by suit
(setvar "pdmode" 34)

 

 

change also first line to

(defun C:zlb (/ acsp adoc mtx pt str util txtsize)

 

2. "###" it appears at the begining when mtext is created follow with the comment temporary any string

which is updated (replaced with FIELD)

 

(setq mtx (vla-addmtext acsp pt 0.0 "###")) ;any string

3. 

 

 

Chris

 

 

0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant

@JB-T wrote:

 

...

Finally, I know there is a way to use a comma as decimal separator (vl-string-subst "," ".") but I don't know where to insert it in the code.

 

...

Can't use this method. You need to set correct field format >> see the screenshot.

 

Change

">%).InsertionPoint \\f \"%lu2%pt4\">%"

to 

">%).InsertionPoint \\f \"%lu2%pt4%ds44\">%"

 

Message 4 of 5

JB-T
Enthusiast
Enthusiast

Thank you both for your answers.

 

It fixed the text height and the decimal separator issues.

 

Would it be possible to modify something in the routine in order to have the elevation displayed immediately instead of "###".

 

 

Thank you again !

 

 

JB

0 Likes
Message 5 of 5

krzysztof.psujek
Advocate
Advocate

Hi, if we helped - please mark our posts as a solutions.

 

To achieve what you want there is no need use any lisp.

You can do it by yourself.

Just defining block with fileds in attributes - even better solution than this with mtext description.

 

Take a look at this thread (but offcourse change X,Y coordinates and leave Z in this case).

 

http://www.cad-notes.com/how-to-label-coordinate-in-autocad/

 

It isn't hard to change this lisp but I think it will be better for you if you will try to do it by yourself and learn something new.

Merry Christmas.

Chris

0 Likes