David Bethel Posted October 8, 2010 Posted October 8, 2010 You are comparing strings in your ( cond ) call (= vps "0.02") but you are declaring vps to have 4 decimal places (setq vps (rtos (/ vs ys) 2 4)) "0.0200" the ( = ) call compares exact string values to use a numerical comparisson, you will need to use the ( equal ) call with a fuzz factor (equal 0.02 (/ vs ys) 1e-2) division of real numbers (/ vs ys) can return up to 15 significant places (equal 0.02 0.02000001 1e-2) Returns T 1e-2 = 0.01 in scientific notaion. -David Quote
woodman78 Posted October 8, 2010 Author Posted October 8, 2010 This is what I have now so David: (defun c:vpdisp (/ cv ss en ed ys vs vps b c) (command "_.insert" "CCC_Drawing_Dim_Leader_Styles=" nil) (command "_.purge" "_b" "CCC_Drawing_Dim_Leader_Styles" "_n") (command "_.MSPACE") (if (/= (getvar "TILEMODE") 0) (setvar "TILEMODE" 0)) (if (/= (getvar "CVPORT") 1) (progn (setq ss (ssget "X" (list (cons 0 "VIEWPORT")(cons 69 (getvar "CVPORT")))) en (ssname ss 0) ed (entget en) cv (cdr (assoc 69 ed)) ys (cdr (assoc 41 ed))) (command "_.PSPACE") ;(setvar "CVPORT" cv) (setq vs (getvar "VIEWSIZE")) (setq vps (rtos (/ vs ys) 2 4)) (princ (strcat "\nThe VIEWPORT Scale is 1 = " (rtos (/ vs ys) 2 4))) ;(setq vps "0.8") ;(alert "\nYour Are Not In An Active MODELSPACE Viewport") ) ) (cond ((equal 0.02 (/ vs ys) 1e-2)(setq b "CCC_1_50000_Dims")(setq c "CCC_Leader_1_50000")) ((equal 0.04 (/ vs ys) 1e-2)(setq b "CCC_1_25000_Dims")(setq c "CCC_Leader_1_25000")) ((equal 0.05 (/ vs ys) 1e-2)(setq b "CCC_1_20000_Dims")(setq c "CCC_Leader_1_20000")) ((equal 0.1 (/ vs ys) 1e-1)(setq b "CCC_1_10000_Dims")(setq c "CCC_Leader_1_10000")) ((equal 0.2 (/ vs ys) 1e-1)(setq b "CCC_1_5000_Dims")(setq c "CCC_Leader_1_5000")) ((equal 0.4 (/ vs ys) 1e-1)(setq b "CCC_1_2500_Dims")(setq c "CCC_Leader_1_2500")) ((equal 0.5 (/ vs ys) 1e-1)(setq b "CCC_1_2000_Dims")(setq c "CCC_Leader_1_2000")) ((equal 0.8 (/ vs ys) 1e-1)(setq b "CCC_1_1250_Dims")(setq c "CCC_Leader_1_1250")) ((equal 1 (/ vs ys))(setq b "CCC_1_1000_Dims")(setq c "CCC_Leader_1_1000")) ((equal 2 (/ vs ys))(setq b "CCC_1_500_Dims")(setq c "CCC_Leader_1_500")) ((equal 4 (/ vs ys))(setq b "CCC_1_250_Dims")(setq c "CCC_Leader_1_250")) ((equal 5 (/ vs ys))(setq b "CCC_1_200_Dims")(setq c "CCC_Leader_1_200")) ((equal 8 (/ vs ys))(setq b "CCC_1_125_Dims")(setq c "CCC_Leader_1_125")) ((equal 10 (/ vs ys))(setq b "CCC_1_100_Dims")(setq c "CCC_Leader_1_100")) ((equal 20 (/ vs ys))(setq b "CCC_1_50_Dims")(setq c "CCC_Leader_1_50")) ((equal 40 (/ vs ys))(setq b "CCC_1_25_Dims")(setq c "CCC_Leader_1_25")) ((equal 50 (/ vs ys))(setq b "CCC_1_20_Dims")(setq c "CCC_Leader_1_20")) ((equal 100 (/ vs ys))(setq b "CCC_1_10_Dims")(setq c "CCC_Leader_1_10")) ) (command "_.dimstyle" "r" b) (prin1)) The problem I have is that the viewport scale calc is still wrong. The viewport scale always seems to be close to 1 no matter how much i change the actual scale. Quote
David Bethel Posted October 8, 2010 Posted October 8, 2010 (defun c:vpdisp (/ cv ss en ed ys vs vps b c) (command "_.insert" "CCC_Drawing_Dim_Leader_Styles=" nil) (command "_.purge" "_b" "CCC_Drawing_Dim_Leader_Styles" "_n") (command "_.MSPACE") (if (/= (getvar "TILEMODE") 0) (setvar "TILEMODE" 0)) (if (/= (getvar "CVPORT") 1) (progn (setq ss (ssget "X" (list (cons 0 "VIEWPORT")(cons 69 (getvar "CVPORT")))) en (ssname ss 0) ed (entget en) cv (cdr (assoc 69 ed)) ys (cdr (assoc 41 ed))) (command "_.PSPACE") ;(setvar "CVPORT" cv) (setq vs (getvar "VIEWSIZE")) (setq vps (rtos (/ vs ys) 2 4)) (princ (strcat "\nThe VIEWPORT Scale is 1 = " (rtos (/ vs ys) 2 4))) ;(setq vps "0.8") ;(alert "\nYour Are Not In An Active MODELSPACE Viewport") ) ) (cond ((equal 0.02 (/ vs ys) 1e-2)(setq b "CCC_1_50000_Dims")(setq c "CCC_Leader_1_50000")) ((equal 0.04 (/ vs ys) 1e-2)(setq b "CCC_1_25000_Dims")(setq c "CCC_Leader_1_25000")) ((equal 0.05 (/ vs ys) 1e-2)(setq b "CCC_1_20000_Dims")(setq c "CCC_Leader_1_20000")) ((equal 0.1 (/ vs ys) 1e-1)(setq b "CCC_1_10000_Dims")(setq c "CCC_Leader_1_10000")) ((equal 0.2 (/ vs ys) 1e-1)(setq b "CCC_1_5000_Dims")(setq c "CCC_Leader_1_5000")) ((equal 0.4 (/ vs ys) 1e-1)(setq b "CCC_1_2500_Dims")(setq c "CCC_Leader_1_2500")) ((equal 0.5 (/ vs ys) 1e-1)(setq b "CCC_1_2000_Dims")(setq c "CCC_Leader_1_2000")) ((equal 0.8 (/ vs ys) 1e-1)(setq b "CCC_1_1250_Dims")(setq c "CCC_Leader_1_1250")) ((equal 1 (/ vs ys))(setq b "CCC_1_1000_Dims")(setq c "CCC_Leader_1_1000")) ((equal 2 (/ vs ys))(setq b "CCC_1_500_Dims")(setq c "CCC_Leader_1_500")) ((equal 4 (/ vs ys))(setq b "CCC_1_250_Dims")(setq c "CCC_Leader_1_250")) ((equal 5 (/ vs ys))(setq b "CCC_1_200_Dims")(setq c "CCC_Leader_1_200")) ((equal 8 (/ vs ys))(setq b "CCC_1_125_Dims")(setq c "CCC_Leader_1_125")) ((equal 10 (/ vs ys))(setq b "CCC_1_100_Dims")(setq c "CCC_Leader_1_100")) ((equal 20 (/ vs ys))(setq b "CCC_1_50_Dims")(setq c "CCC_Leader_1_50")) ((equal 40 (/ vs ys))(setq b "CCC_1_25_Dims")(setq c "CCC_Leader_1_25")) ((equal 50 (/ vs ys))(setq b "CCC_1_20_Dims")(setq c "CCC_Leader_1_20")) ((equal 100 (/ vs ys))(setq b "CCC_1_10_Dims")(setq c "CCC_Leader_1_10")) ) [color="red"] (textpage) (foreach v '("b" "c" "vs" "ys" "vps") (princ (strcat "\n" v " = ")) (prin1 (eval (read v)))) (getstring "\nPress Enter To Continue: ") [/color] (command "_.dimstyle" "r" b) (prin1)) YOU HAVE TO USE THE FUZZ FACTOER ON ALL (equal) CALLS! Try this to see the variable settings. -David Quote
woodman78 Posted October 13, 2010 Author Posted October 13, 2010 I tried that David and while I could see the variables I didn't know what I should be looking for. Quote
woodman78 Posted October 20, 2010 Author Posted October 20, 2010 Can anyone help with this? I am trying to get the viewport scale? Quote
David Bethel Posted October 20, 2010 Posted October 20, 2010 I tried that David and while I could see the variables I didn't know what I should be looking for. What were the values? -David Quote
woodman78 Posted October 20, 2010 Author Posted October 20, 2010 David, This is what the code gives back: Command: The VIEWPORT Scale is 1 = 0.9657 b = nil c = nil vs = 548.295 vps = "0.9657" Press Enter To Continue: And this is the actual viewport scale Quote
David Bethel Posted October 20, 2010 Posted October 20, 2010 As long as b & c return nil, your program cannot work You do not have test for (equal 0.9657 (/ vs ys) 1e-4) and I would not think that to be a proper scale. As you see the Height and vs values do not match. They should. It may have something to do with custom scale that is set in the 'Misc' data box. I know nothing about what it means or how it is set? Maybe someone can jump in a different view. -David Quote
JohnM Posted October 20, 2010 Posted October 20, 2010 Just curious, could you explain what you want to accomplish. From what I have read you want to be in paper space and click on a viewport then change you dimstyle and leader style to scale to that viewport scale. (I could be wrong) If I’m correct, here is what I have. I have a dimstyle named FULL and a text style named DIM. My DIM text style has a height of 0.00 My dimstyle FULL references the DIM text and I have the text height set to 0.09375 (I like 3/32 text height) So as long as my current dim style is set to full when I go to paper space and click inside a viewport to dimension or leader something AutoCAD does the calculations for me and will scale the text or leader to the correct size making my text 3/32 high no mater what the viewport scale is. I could go on but I might be off base on what you want to achieve. Quote
woodman78 Posted October 21, 2010 Author Posted October 21, 2010 Yes John, that sounds about right. My idea was that because we only put drawings of 1 scale in a dwg file, that the scale of the viewport would be read and this would set the dimstyle and mleader style. Am I way off the mark here. Quote
JohnM Posted October 21, 2010 Posted October 21, 2010 I think you need to plan it out in detail to figure out all the issues. If you want it to automatically set the styles then your looking at using reactors but that opens up a whole new can of worms. Or do you want to type in a command or click a button to run the program? Could you give a step-by-step detail of what you want to happen? What if a new drawing is opened? What if someone messed up the vp scale? Quote
alanjt Posted October 21, 2010 Posted October 21, 2010 Why not just have one Dimstyle that bases everything on a percentage of the annotative scale (if annotative) or the dimscale? Quote
woodman78 Posted October 26, 2010 Author Posted October 26, 2010 How would i go about that Alanjt? How would I set things up as a percentage? Quote
irneb Posted October 27, 2010 Posted October 27, 2010 In the DimStyle dialog's Fit tab, simply set the "Scale for dimension features" (2nd from bottom right) to "Scale dimensions to layout". That way you use one single dimstyle, and it adjusts to whatever the VP is scaled to. For this you have to do your dims either on top of PS or through one of the VPs. Alternatively, set your dimstyle to Annotative (in the same area as above). Then it will assume the scaling as per your current CAnnoScale sysvar - which is 1:1 on top of PS, and set individually per VP and MS. Quote
Recommended Posts
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.