Jump to content

Changing properties of this lisp, please help...


Nellie

Recommended Posts

HI,

 

Can someone please help, I've been trying to change the properties of a usefull lisp i use.

 

This lisp gives me a level value each time i pick a point but I would like to change the linetype & point marker.

 

Has anyone any ideas how to change this?

 

Thanks in advance.

 

Nelie.

 

Lisp below.

 

(defun c:txm()
(terpri)
;; Perform math on text numbers in-place, by Carl B., coded March 2000
(setvar "cmdecho" 0)
;; select lines to annotate
(setq mfactor 1 afactor 0 input nil)
(initget "M A")
(setq input (getkword "\nMultiply<M> or Add<A>?: "))
(cond
((= input "M") (initget 1)
(setq mfactor (getreal "\nMult Factor: ")))
((= input "A") (initget 1)
(setq afactor (getreal "\nAdd Amount: ")))
(T nil)
) ; cond
(initget 1)
(setq precis (getint "\nPlaces after decimal: "))
(setq units (getstring T "\nEnter units to append: "))
(princ "\nSelect text to revise: ")
(setq textset nil)
(while (not textset) (setq textset (ssget '((0 . "*TEXT")))))
(setq numitems (sslength textset))
;; loop to isolate text & change text
(setq itemno 0)
(repeat numitems
(setq entname (ssname textset itemno))
;;(setq enttype (cdr (assoc 0 (entget entname))))
(setq oldtxt_pr (assoc 1 (entget entname)))
(setq oldtxt (cdr oldtxt_pr))
(setq oldtext# (atof oldtxt))
(setq newtext# (+ (* oldtext# mfactor) afactor))
(setq newtxt (strcat (rtos newtext# 2 precis) units))
(setq newtxt_pr (cons 1 newtxt))
(setq entstuff (entget entname))
(setq entstuff (subst newtxt_pr oldtxt_pr entstuff))
(entmod entstuff)
(setq itemno (1+ itemno))
) ; repeat
(princ)
) ; the end
(princ "Do math on text Start with \"TXM\"")
(princ)

Link to comment
Share on other sites

I am capable to help if you specify your requirements. ...i just need to change the text style and point marker. - here is not enough information to make something.

Link to comment
Share on other sites

Nellie,

 

If I understand it correctly, (and correct me if I am wrong), but the LISP that you are using is a program that will perform some math on text that contains numbers.

 

When you say

 

I would like to change the linetype & point marker

 

Do you mean change the text style?

Link to comment
Share on other sites

Hi Guys,

 

Sorry for not giving the right info guys.

 

This lisp is curently creating the level (text style) as Standard-Courier New at a height of 0.2 but i would like it at Standard-Simple at a height of 0.18.

 

I would also like the arrow which is currently being created to be replaced by a cross (+) with a 0.18 size.

 

Thanks again in advance.

 

Nellie

Link to comment
Share on other sites

...but i would like it at Standard-Simple at a height of 0.18

 

Do you mean Simplex.shx font?

 

Try this. It creates block with attribute LEVEL and cross marker and adds "Simplex" style automaytically.

 

(defun c:lemar(/ sCol bCol nStl nBlk
          cBlk nAtr ln1 ln2 cAtr)
 
(vl-load-com)
 
(setq aDoc(vla-get-ActiveDocument
      (vlax-get-acad-object))
     sCol(vla-get-TextStyles aDoc)
     bCol(vla-get-Blocks aDoc)
     ); end setq
 (if(vl-catch-all-error-p(vl-catch-all-apply 'vla-Item
 (list sCol "Simplex")))
    (progn
      (setq nStl(vla-Add sCol "Simplex"))
      (vla-put-FontFile nStl "simplex.shx")
     ); end progn
   ); end if
 (if(vl-catch-all-error-p(vl-catch-all-apply 'vla-Item
 (list bCol "Level Marker")))
   (progn
   (setq nBlk(vla-Add bCol
	       (vlax-3D-point '(0 0 0))
	       "Level Marker"))
   (setq nAtr(vla-AddAttribute nBlk 0.18 acAttributeModePreset
                     "" (vlax-3D-point '(0 0 0)) "LEVEL" "X"))
   (vla-put-Alignment nAtr acAlignmentBottomCenter)
   (vla-put-StyleName nAtr "Simplex")
   (vla-put-TextAlignmentPoint nAtr
     (vlax-3D-point '(0.0 0.1 0.0)))
   (setq ln1(vla-AddLine nBlk(vlax-3D-Point '(-0.09 0.0 0.0))
                    (vlax-3D-Point '(0.09 0.0 0.0)))
         ln2(vla-AddLine nBlk(vlax-3D-Point '(0.0 -0.09 0.0))
                    (vlax-3D-Point '(0.0 0.09 0.0))))
   (mapcar 'vla-put-Layer '(nAtr ln1 ln2) '("0" "0" "0"))
    ); end progn
   ); end if
 (princ "\nPlace level marker or Right Click to Quit> ")
 (while(setq cPt(getpoint))
   (setq cBlk(vla-InsertBlock(vla-get-ModelSpace aDoc)
	(vlax-3D-Point cPt)"Level Marker"
	 1.0 1.0 1.0 0.0)
  cAtr(car(vlax-safearray->list
       (vlax-variant-value(vla-GetAttributes cBlk)))))
   (vla-put-TextString cAtr(rtos(cadr cPt)2 2))
   ); end while
 (princ)
 ); end of c:lemar

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