TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on June 28, 2012, 05:53:10 AM
-
for scale 1:100
how to calculate magnification
(vla-zoomcenter (vlax-get-acad-object) (vlax-3d-point mp) magnification)
Thanks
-
Use the ZoomCenter method with any arbitrary zoom magnification to position the objects in the Viewport, then set the CustomScale property of the Viewport to obtain the correct scale (or, in your case with a scale of 1:100, you can use the StandardScale property with the acVp1_100 enum).
-
But not working, There is something missed
(setq scl (cond ((getint (strcat "\nWhat is Viewport Scale 1: <" (itoa (setq scl (cond (scl) (50)))) ">: " ))) (scl)))
(setq VPDoc (vla-get-PaperSpace doc))
(setq VPp (vlax-3D-point (getpoint "\nSelect Point for Viewport")))
(setq VP (vla-AddPViewport VPDoc VPp (/ (- (car p2) (car p1)) scl) (/ (- (cadr p2) (cadr p1)) scl)))
(vla-zoomcenter (vlax-get-acad-object) (vlax-3d-point mp) 1)
(vla-put-StandardScale VP (* 1000 scl))
(vla-put-customscale VP (* 1000 scl))
-
Here is for model space - you must measure active AutoCAD with area on your monitor...
(vl-load-com)
(defun magnif ( / proportion wid magnification )
(initget 6)
(setq proportion (getreal "\nEnter proportion ratio (1:100=0.01) <0.01> : "))
(if (null proportion) (setq proportion 0.01))
(initget 6)
(setq wid (getreal "\nEnter with of screen active AutoCAD area in cm <36.0 cm> : "))
(if (null wid) (setq wid 36.0))
(vl-cmdf "_.zoom" "w" '(0.0 0.0 0.0) (list wid 0.0 0.0))
(setq magnification (* (getvar 'viewsize) (/ 1.0 proportion)))
(vl-cmdf "_.zoom" "p")
magnification
)
(defun c:zoomratio ( / mp )
(setq mp (getpoint "\nPick center point for zoom : "))
(vla-zoomcenter (vlax-get-acad-object) (vlax-3d-point mp) (magnif))
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)
(princ)
)
M.R.
Supose you can do the same for paperspace viewport (I think measure VP width in cm)...
-
try to get some info from here
1. draw closed object over viewport
2. type det
3. select viewport
4. select object
5. pick point and scale
works only with world ucs
kruuger
-
You should use a combination of MP's VPCORDS function and Gile's PCS2WCS function.
-
you must measure active AutoCAD with area on your monitor...
How to measure this area?
Edit:
Is it (getvar "screensize")
-
Is this solution good?
(vla-zoomcenter (vlax-get-acad-object) (vlax-3d-point mp) 1.0)
(vl-cmdf "_.zoom" SCL)
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)
;(vla-put-StandardScale VP (/ 1.0 sc))
;(vla-put-customscale VP (/ 1.0 sc))
-
You take real tape with measurments (cm), and measure width of active model space viewport, or if you are in paper space, you measure active viewport and apply the code with active MSPACE (viewport)... The result is scale 1:100 on the screen (100 dwg units = 100 cm = 1 m => 1:100 (1 cm on screen)...
M.R.
-
...
The result is scale 1:100 on the screen (100 dwg units = 100 cm = 1 m => 1:100 (1 cm on screen)...
M.R.
I am working in mm so
(100 dwg units = 10 cm = 0.1 m => 1:10 (0.1 cm on screen)
Is it correct?
-
...
The result is scale 1:100 on the screen (100 dwg units = 100 cm = 1 m => 1:100 (1 cm on screen)...
M.R.
I am working in mm so
(100 dwg units = 10 cm = 0.1 m => 1:10 (0.1 cm on screen)
Is it correct?
No, this is correct :
(100 dwg units = 10 cm = 0.1 m => 1:100 (0.1 cm on screen)
(100 dwg units = 10 cm = 0.1 m => 1:10 (1 cm on screen)
M.R.
-
I think that my code is confusing you, for you are working in mm...
So the code should be :
(vl-load-com)
(defun magnif ( / proportion wid magnification )
(initget 6)
(setq proportion (getreal "\nEnter proportion ratio (1:100=0.01) <0.01> : "))
(if (null proportion) (setq proportion 0.01))
(initget 6)
(setq wid (getreal "\nEnter with of screen active AutoCAD area in cm <360 mm> : "))
(if (null wid) (setq wid 360))
(vl-cmdf "_.zoom" "w" '(0.0 0.0 0.0) (list wid 0.0 0.0))
(setq magnification (* (getvar 'viewsize) (/ 1.0 proportion)))
(vl-cmdf "_.zoom" "p")
magnification
)
(defun c:zoomratio ( / mp )
(setq mp (getpoint "\nPick center point for zoom : "))
(vla-zoomcenter (vlax-get-acad-object) (vlax-3d-point mp) (magnif))
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)
(princ)
)
Note : You must measure width of active viewport in mm - this is your measurment setting...
M.R.
-
Is it mean for scale 1:100 we use wind 360mm?
so we can make relation like this
(setq scl (cond ((getint (strcat "\nWhat is Viewport Scale 1: <" (itoa (setq scl (cond (scl) (50)))) ">: " ))) (scl)))
(setq wid (* 3.6 scl))
(vla-zoomcenter (vlax-get-acad-object) (vlax-3d-point mp) (* (getvar 'viewsize) scl))
Another solution
Could we do this
(setq sc (cond ((getint (strcat "\nWhat is Viewport Scale 1: <" (itoa (setq sc (cond (sc) (50)))) ">: " ))) (sc)))
(setq scl (strcat (RTOS (/ 1.0 SC)) "xp"))
...
(vl-cmdf "_.zoom" SCL)
Thanks for your quick reply
-
Look HasanCAD, my settings of AutoCAD active model space viewport measured on my monitor with real tape is 36 cm, and therefore I put that value into my code... This can be modified to suite any one's needs, as there are various types of monitors, and settings of AutoCAD may also vary... So consider to implement your standard into code measured with measurments that you use (mm) - someone maybe use inches, so he/she must measure width in inches and modify standard into the code... My code is made to consider all possible ratio proportions (100:1; 10:1, 2:1, 1:1, 1:2, 1:10, 1:100, 1:1000, ...) so when executing the code my set standard was as you wanted 1:100 (0.01), so be careful when entering ratios as screen representation of proportions for sure is dependable on what user enter...
Test my revised code for your needs and enter width of viewport in your measurment system (mm)... Representation on screen should meet required scale ratio that you enter... So 100 dwg=10 cm=0.1 m=100 mm => width in mm, 1:10 => 100 mm in real world will become 10 times smaller 10 mm = 1 cm...
This should be true on screen...
M.R.
-
To get the current scale use:the rest as mentioned
Cheers