Jump to content

Recommended Posts

Posted

WHEN I WORK WITH LAYOUT. I USE COMMAND MVIEW FOR CREATE A VIEWPORT. I USE THIS LISP TO MODIFY SCALE VIEWPORT BY CLICK ON FRAME VIEWPORT. BUT WHEN I USE COMMAND MVIEW>OBJECT AND CLICK OBJECT EX.:CIRLCE OR RECTANG, MY LISP NO VALUE.

THANK FOR ALL

(defun c:WQQ(/ ent dz Viewport newVal)
 (if (/= (getvar "cvport") 1)
   (alert "\nChi co the chay tren khong gian giay (Layout).")
   (progn
     (while
(not (and
       (setq ent (car (entsel "\nChon Viewport : ")))
       (if ent (= (cdr (assoc 0 (entget ent))) "VIEWPORT") )
       )
     )
(princ "\nkhong phai Viewport. Chon lai : ")
)
     (setq dz (getvar "dimzin"))
     (setvar "dimzin" 8 )
     (setq Viewport (vlax-Ename->Vla-Object ent)
    newVal (GetScale (getstring(strcat "\nNhap Scale Standard (vd. 1/50, 1:50, 50 ) <" ( getvport_scale Viewport)"> :")) ))
     (if newVal (vla-put-CustomScale Viewport newVal))
     (setvar "dimzin" dz )
     )
   )
 (princ)
 )

(defun GetScale (Str  / Sc)
 (cond
   ((/= (type Str) 'STR) nil)
   ((or (setq Pos (vl-string-search ":" Str))(setq Pos (vl-string-search "/" Str)))
    (setq Sc (vl-catch-all-apply
	'(lambda () (/ (distof (substr Str 1 Pos)) (distof (substr Str (+ 2 Pos)))) ) ) ) )
   ((setq Sc (vl-catch-all-apply '(lambda () (/ 1 (distof Str))))))
   )
 (if (vl-catch-all-error-p Sc)
   (setq Sc nil)
   )
 Sc
 )

(defun getvport_scale (viewport / sc csc)
 (setq sc (vla-get-StandardScale viewport))
   (cond
     ((= sc acVpScaleToFit)
      (setq csc 1.0)
     )
     ((= sc acVpCustomScale)
      (setq csc (/ 1 (vla-get-CustomScale viewport)))
      (if (= csc 0.0) (setq csc 1.0))
     )
     ((= sc acVp1_128in_1ft) (setq csc 1536.0))
     ((= sc acVp1_64in_1ft) (setq csc 768.0))
     ((= sc acVp1_32in_1ft) (setq csc 384.0))
     ((= sc acVp1_16in_1ft) (setq csc 192.0))
     ((= sc acVp3_32in_1ft) (setq csc 128.0))
     ((= sc acVp1_8in_1ft) (setq csc 96.0))
     ((= sc acVp3_16in_1ft)(setq csc 64.0))
     ((= sc acVp1_4in_1ft) (setq csc 48.0))
     ((= sc acVp3_8in_1ft) (setq csc 32.0))
     ((= sc acVp1_2in_1ft) (setq csc 24.0))
     ((= sc acVp3_4in_1ft) (setq csc 16.0))
     ((= sc acVp1in_1ft) (setq csc 12.0))
     ((= sc acVp3in_1ft)(setq csc 4.0))
     ((= sc acVp6in_1ft)(setq csc 2.0))
     ((= sc acVp1ft_1ft)(setq csc 1.0))
     ((= sc acVp1_1) (setq csc 1.0))
     ((= sc acVp1_2) (setq csc 2.0))
     ((= sc acVp1_4) (setq csc 4.0))
     ((= sc acVp1_ (setq csc 8.0))
     ((= sc acVp1_10) (setq csc 10.0))
     ((= sc acVp1_16) (setq csc 16.0))
     ((= sc acVp1_20) (setq csc 20.0))
     ((= sc acVp1_30) (setq csc 30.0))
     ((= sc acVp1_40) (setq csc 40.0))
     ((= sc acVp1_50) (setq csc 50.0))
     ((= sc acVp1_100)(setq csc 100.0))
     ((= sc acVp2_1) (setq csc 0.5))
     ((= sc acVp4_1) (setq csc 0.25))
     ((= sc acVp8_1) (setq csc 0.125))
     ((= sc acVp10_1) (setq csc 0.1))
     ((= sc acVp100_1) (setq csc 0.01))
   )
 (if (member (getvar "lunits") '(1 2 3 5))
    (strcat "1:" (rtos csc ))
    (strcat (rtos (/ 12 csc) 4 5) "=" (rtos 12 4))
   )
 )

Posted

Hi Vu, Please do not use the Capital Letter for typing your question,

So, your mean is Viewport scale?

Posted

Thanks ! i try again.

viewport scale mean: i want to zoom to object with 1/100, i use my lisp and click frame viewport. you can test with my lisp in layout !

Thanks test and help me !

Hi Vu, Please do not use the Capital Letter for typing your question,

So, your mean is Viewport scale?

Posted

Check this.....

 

(defun c:Test (/ vp sc vl)(vl-load-com)
 ; Tharwat 06. 06. 2011
 (if (and (setq vp (ssget "_:L" '((0 . "VIEWPORT"))))
          (setq sc (getdist "\n Enter scale factor for Viewport :"))
     )
     (vla-put-CustomScale (vlax-ename->vla-object (ssname vp 0)) sc)
   (princ)
 )
 (princ)
)

 

Tharwat

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