Jump to content

correct the code here- help


muthu123

Recommended Posts

Dear all,

 

Please correct the code at last line to update the width by "(vlax-put-property lay 'width (* 0.75 width_old) )".

Please help.

 

(defun style_change_to_avoid_bug_in_text_Selection (/ get->styleobj a width_old)
 (defun get->styleobj () (vla-get-textstyles (vla-get-ActiveDocument (vlax-get-acad-object))))
 (vlax-for lay (get->styleobj)
   (Setq a (strcase (vlax-get-property lay 'FontFile)))
   (if (= (substr a (- (strlen a) 2) (strlen a)) "TTF")
     (progn (Setq name_Style (vlax-get-property lay 'Name))
            (setq width_old (vlax-get-property lay 'width))
            (vlax-put-property lay 'FontFile "romand.shx")
        (vlax-put-property lay 'width (* 0.75 width_old) )
            ;;;(vlax-put-property lay 'width (rtos (* 0.75 width_old) 2 2))
     )
   )
 )
 (command "regen")
)

Link to comment
Share on other sites

It seems to work for me:

 

(defun test ( / a name_style width_old)
 
 (vlax-for sty (vla-get-textstyles
                 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))
   
   (setq a (strcase (vlax-get-property sty 'FontFile)))

   (if (eq (substr a (- (strlen a) 2)) "TTF")
     (progn
       (setq name_Style (vlax-get-property sty 'Name))
       (setq width_old  (vlax-get-property sty 'width))
       (vlax-put-property sty 'FontFile "romand.shx")
       (vlax-put-property sty 'width (* 0.75 width_old))
     )
   )
 )
 (vla-regen doc acActiveViewport)
 (princ)
)

Link to comment
Share on other sites

It seems to work for me:

 

(defun test ( / a name_style width_old)

 (vlax-for sty (vla-get-textstyles
                 (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))

   (setq a (strcase (vlax-get-property sty 'FontFile)))

   (if (eq (substr a (- (strlen a) 2)) "TTF")
     (progn
       (setq name_Style (vlax-get-property sty 'Name))
       (setq width_old  (vlax-get-property sty 'width))
       (vlax-put-property sty 'FontFile "romand.shx")
       (vlax-put-property sty 'width (* 0.75 width_old))
     )
   )
 )
 (vla-regen doc acActiveViewport)
 (princ)
)

 

 

Thank you lee for your modification in my code. I want this in the following code also. Please help and do you have anyother logic to achieve this task?

 

  (defun style_change (/ a name_style width_old)
   (vlax-for sty (vla-get-textstyles (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))
     (setq a (strcase (vlax-get-property sty 'FontFile)))
     (if (eq (substr a (- (strlen a) 2)) "TTF")
       (progn (setq name_Style (vlax-get-property sty 'Name))
              (setq width_old (vlax-get-property sty 'width))
              (vlax-put-property sty 'FontFile "romand.shx")
              (Setq sset (ssget "x" (list (cons 7 name_Style))))
              (Setq #k 0)
              (repeat (sslength sset)
                (Setq ename (ssname sset #k))
                (Setq vlobj (vlax-ename->vla-object ename))
                (if (vlax-property-available-p vlobj 'width)
                  (vla-put-width vlobj (* 0.75 width_old))
                  (vla-put-scalefactor vlobj (* 0.75 width_old))
                )
                (Setq #k (1+ #k))
              )
       )
     )
   )
   (vla-regen doc acActiveViewport)
   (princ)
 )

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