Jump to content

Need some modification in this Lisp...


Saqib_theleo

Recommended Posts

Hello to all,

I found this Block Size Lisp from somewhere and it works fine. After running this Lisp it asks for Select Objects then hit enter for scale factor and give it the value for scale factor then hit enter and it scales selected blocks.

But I want this Lisp work in this way that after running this Lisp it asks for select objects and when you hit enter it automatically select the Scale Factor and the value of "0.02".

If someone can help me I'll be thankfull for that.

 

(defun C:SIZE (/ sngScaleFactor 
                ssSelections 
                strScaleOption
             )
(princ "\nSelect items to size individually by their own insertion point: ")
(setq ssSelections   (ssget (list (cons 0 "ATTDEF,INSERT,MTEXT,TEXT"))))
(initget "I F")
(setq strScaleOption (getkword "\n[i]nsertion Scale or Scale [F]actor: "))
(initget 6)
(setq sngScaleFactor (getdist "\nEnter Scale Factor: "))
(vlax-for objItem (vla-get-activeselectionSet 
                   (vla-get-activedocument 
                    (vlax-get-acad-object)))
 (if (wcmatch (vla-get-objectname  objItem) 
              "AcDbBlockReference,AcDbMInsertBlock")
  (if (= strScaleOption "F")
   (progn
    (vlax-put objItem "xscalefactor" (* sngScaleFactor (vlax-get objItem "xscalefactor")))
    (vlax-put objItem "yscalefactor" (* sngScaleFactor (vlax-get objItem "yscalefactor")))
    (vlax-put objItem "zscalefactor" (* sngScaleFactor (vlax-get objItem "zscalefactor")))
   )
   (progn
    (vlax-put objItem "xscalefactor" sngScaleFactor)
    (vlax-put objItem "yscalefactor" sngScaleFactor)
    (vlax-put objItem "zscalefactor" sngScaleFactor)
   )
  )
  (if (= strScaleOption "F")    
   (vlax-put objItem "height" (* sngScaleFactor (vlax-get objItem "height")))
   (vlax-put objItem "height" sngScaleFactor)
  )   
 )
)
(prin1)
)

Link to comment
Share on other sites

(defun C:SIZE (/ sngScaleFactor 
                ssSelections 
                strScaleOption
             )
(princ "\nSelect items to size individually by their own insertion point: ")
(setq ssSelections   (ssget (list (cons 0 "ATTDEF,INSERT,MTEXT,TEXT"))))
[color="royalblue"] ;(initget "I F")
;(setq strScaleOption (getkword "\n[i]nsertion Scale or Scale [F]actor: "))
;(initget 6)[/color]
(setq sngScaleFactor [color="red"]0.02[/color]) ; [color="red"]scale value[/color]
(vlax-for objItem (vla-get-activeselectionSet 
                   (vla-get-activedocument 
                    (vlax-get-acad-object)))
 (if (wcmatch (vla-get-objectname  objItem) 
              "AcDbBlockReference,AcDbMInsertBlock")
  (if (= strScaleOption "F")
   (progn
    (vlax-put objItem "xscalefactor" (* sngScaleFactor (vlax-get objItem "xscalefactor")))
    (vlax-put objItem "yscalefactor" (* sngScaleFactor (vlax-get objItem "yscalefactor")))
    (vlax-put objItem "zscalefactor" (* sngScaleFactor (vlax-get objItem "zscalefactor")))
   )
   (progn
    (vlax-put objItem "xscalefactor" sngScaleFactor)
    (vlax-put objItem "yscalefactor" sngScaleFactor)
    (vlax-put objItem "zscalefactor" sngScaleFactor)
   )
  )
  (if (= strScaleOption "F")    
   (vlax-put objItem "height" (* sngScaleFactor (vlax-get objItem "height")))
   (vlax-put objItem "height" sngScaleFactor)
  )   
 )
)
(prin1)
)
  

 

 

Blocked codes in blue color

 

try this lisp

Link to comment
Share on other sites

A slight variation

 

(defun SIZE ( sngScaleFactor /  

; (setq sngScaleFactor [color=red]0.02[/color]) ; [color=red]scale value[/color]

Then to call type (size 0.2) can change size this way

Link to comment
Share on other sites

A slight variation

 

(defun SIZE ( sngScaleFactor /  

; (setq sngScaleFactor [color=red]0.02[/color]) ; [color=red]scale value[/color]

Then to call type (size 0.2) can change size this way

 

Hey BIGAL,

 

Dont get me wrong.

But why would you choose this solution, instead of just setting 'setq' to a forced number?

Link to comment
Share on other sites

I tried this on annotative text..

somehow it put height at in it .. 'sngScaleFactor/annoscale'

Would be nice if could be worked out for annotative text.

Link to comment
Share on other sites

Aftertouch You are correct the post was for 0.2 only. When you start reading many posts the first thing is that another requester asks "Can you add 0.2 or 0.4 as an option" "can I just have this added". Hence a more generic possibility for perhaps some one else that may read the post.

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