Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Text placement at set angles Justification/flip and bold styles in lisp

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ssewell123
586 Views, 4 Replies

Text placement at set angles Justification/flip and bold styles in lisp

Hi all,

Im using the code below to place valve numbers at a 45 degree angle to a valve ( just a block) but i have 3 problems.

 

1. the text ROM100 is supposed to be bold - it is set to bold in the text style settings but it changes to regular on load and run of this lisp.

I cant work out how to make text bold through lisp

 

2. I would like to be able to place the number at 45, 135, 225 & 315 degrees to the valve(block) by user moving cursor around and selecting which angle they preffer

 

3. and lastly justification to be MR or ML and number to flip (not be upside down when at 225 and 315 degrees

 

I have seen this done before so i know it can be done but it is beyond me. Can anyone help? I have spent ages trying to work out the cons 10 and 11 with group codes 72 and 73 to place justifications MR ML and BL to no avail.

Code in progress:

(defun C:insvno (/ txtStyle numSeq txtInsert str1 str2)
 (setq txtStyle (getvar "textstyle"))
 (command "STYLE" "ROM100" "Romantic" 4.5 0.89 0 "N" "N")
 (setq numSeq (getint "\nEnter start Valve Number: <500>: "))
 (if (= numSeq nil)(setq numSeq 500))
 (setq txtInsert (getpoint "Select Valve:  "))
 (while txtInsert
  (setq str1 (itoa numSeq))
  (setq str2 (strcat str1))
  (command "TEXT" txtInsert "45" str2)
  (setq txtInsert (getpoint "Select Next Valve:  "))
  (setq numSeq (+ numSeq 1))
 )
 (setvar "textstyle" txtStyle)
 (princ)
)

4 REPLIES 4
Message 2 of 5
dicra
in reply to: ssewell123

Hi ssewell,

 

quick hint for your first task,

(command "STYLE" "ROM100" "Romantic bold" 4.5 0.89 0 "N" "N")

 

dicra

Message 3 of 5
dicra
in reply to: dicra

a quick one,

minimal testing

 

(defun C:insvno (/ txtStyle numSeq txtInsert str1 str2)
 (setq txtStyle (getvar "textstyle"))
 (command "STYLE" "ROM100" "Romantic bold" 4.5 0.89 0 "N" "N")
 (setq numSeq (getint "\nEnter start Valve Number: <500>: "))
 (if (= numSeq nil)(setq numSeq 500))
  (while (setq ins_pt (getpoint "\n Select Valve:  "))   
    
 (setq pt_lst (vectors ins_pt) )
  (setq ;ins_pt (car pt_lst)
	ang_pt (cadr pt_lst)
	)
 (redraw)
  (setq ang (angle ins_pt ang_pt))
  (cond
    ((and (>= ang 0)(< ang (/ pi 2))) (setq ang (/ pi 4) jus acalignmentMiddleleft))
    ((and (>= ang (/ pi 2))(< ang pi)) (setq ang (*(/ pi 4) 7) jus acalignmentMiddleright))
    ((and (>= ang pi)(< ang (* (/ pi 2) 3))) (setq ang (/ pi 4) jus acalignmentMiddleright))
    ((and (>= ang (* (/ pi 2) 3))(< ang (* pi 2))) (setq ang (*(/ pi 4) 7)jus acalignmentMiddleleft))
    )
  (addText ins_pt 45 numseq ang jus)
    (setq numseq (1+ numseq))
 
    );end while
    
 (setvar "textstyle" txtStyle)
 (princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;TEXT
(defun addText (apt ht thestring rotation align / mspace thetext)
  (vl-load-com)

  (setq	mspace (vla-get-modelspace
		 (vla-get-activedocument
		   (vlax-get-acad-object)
		 )
	       )
  )
  (setq	thetext	(vla-AddText
		  mspace
		  thestring
		  (vlax-3d-point apt)
		  ht
		)
  )
  (vla-put-rotation thetext rotation)
  (vla-put-Alignment thetext align)
  (vla-put-TextAlignmentPoint thetext (vlax-3d-point apt))
  (princ)
)					;defun


(defun VECTORS (pt / PT PTLIST)
  ; Sequential choice of points
  ; by ElpanovEvgeniy
  ; (2005-10-19 17:59:01)
  ; (VECTORS)
  ;modified by dicra
  (setq PTLIST (list pt
                 ;(setq PT (getpoint "\n Select Valve:  "))
               ) ;_  list
  ) ;_  setq
  (princ "\n Specify the angle point  ")
  (princ)
  
    (setq PT
           (progn (while
                    (and (setq PT (grread 5))
                         (= (car PT) 5)
                    ) ;_  and
                     (redraw)
                     (mapcar
                       (function
                         (lambda (x1 x2)
                           (grdraw x1 x2 6 5)
                         ) ;_  lambda
                       ) ;_  function
                       (cons (cadr PT) PTLIST)
                       PTLIST
                     ) ;_  mapcar
                  ) ;_  while
                  (if (listp (cadr PT))
                    (cadr PT)
                  ) ;_  if
           ) ;_  progn
    ) ;_  setq
     (setq PTLIST (cons PT PTLIST))
  (reverse ptlist)
  
   ;_  while
)

 If this is what you wan't we will have to put check if style "ROM100" already exist.

If it exist, I think this code is not going to change text style to bold.

 

hope this is going to help you,

dicra

Message 4 of 5
ssewell123
in reply to: dicra

Thanks Dicra

 

Ok that works amazing and the romantic style is bold! I really appreciate your help!

i did have to make one adjustment - the text size came through as 45 not 4.5 but i found that in this line and fixed it :  

(addText ins_pt 45 numseq ang jus)

 

that code is mind boggling for me, i would never have figured that out. 

lots to learn!

 

I really appreciate your help!

Kind Regards,

Shane

 

 

Message 5 of 5
dicra
in reply to: ssewell123

ssewel,

 

You are more than welcome, I'm glad I could help.

 

Most of the stuffs I learned from great people from this forum, so If you are trying to learn, you'r probably on the right place.

 

Cheers,

dicra

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost