KGehrels Posted March 8 Share Posted March 8 I've got code that is switching the dimstyles of dimensions. In order to keep the tolerances I have a section that records the tolerance settings before the change then reapplies them. The issue that I'm having is that, even though the print lines I added for debugging are showing that the tolerance display numbers are the same the tolerance (2 in this case) the tolerance changes from deviation to symmetrical and the tolerance lower limit is changing from 0 to 0.0625. Any thoughts on this odd behaviour? (defun Collate (stylescale dimlist stylename / dimscale tdisp thscale tjust tllimit tprec tsuplz tsuptz tsupzf tsupzi tulimit) (Foreach dim dimlist (setq dimscale (vlax-get-property dim "LinearScaleFactor")) ; Find the scale of each dimension ; Get all tolerance properties (setq tdisp (vlax-get-property dim "ToleranceDisplay")) (setq thscale (vlax-get-property dim "ToleranceHeightScale")) (setq tjust (vlax-get-property dim "ToleranceJustification")) (setq tllimit (vlax-get-property dim "ToleranceLowerLimit")) (setq tprec (vlax-get-property dim "TolerancePrecision")) (setq tsuplz (vlax-get-property dim "ToleranceSuppressLeadingZeros")) (setq tsuptz (vlax-get-property dim "ToleranceSuppressTrailingZeros")) (setq tsupzf (vlax-get-property dim "ToleranceSuppressZeroFeet")) (setq tsupzi (vlax-get-property dim "ToleranceSuppressZeroInches")) (setq tulimit (vlax-get-property dim "ToleranceUpperLimit")) (if (equal dimscale stylescale 0.1) ; Check if the style scale matches the dimension scale (progn ; If true then: (vlax-put-property dim "StyleName" stylename) ; Assign the dimstyle to the dimension (print (strcat "old display: " (itoa tdisp))) ;Apply all tolerance properties from above (vlax-put-property dim "ToleranceDisplay" tdisp) (vlax-put-property dim "ToleranceHeightScale" thscale) (vlax-put-property dim "ToleranceJustification" tjust) (vlax-put-property dim "ToleranceLowerLimit" tllimit) (vlax-put-property dim "TolerancePrecision" tprec) (vlax-put-property dim "ToleranceSuppressLeadingZeros" tsuplz) (vlax-put-property dim "ToleranceSuppressTrailingZeros" tsuptz) (vlax-put-property dim "ToleranceSuppressZeroFeet" tsupzf) (vlax-put-property dim "ToleranceSuppressZeroInches" tsupzi) (vlax-put-property dim "ToleranceUpperLimit" tulimit) (princ (strcat "new display: " (itoa tdisp))) ) ; End progn ) ; End if ) ; End Foreach ) ; End Collate Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 8 Share Posted March 8 Have a look at my post here, a list of all the variables for dimensions (it is the second bit of code that contains the list), might be you need to change another variable? Quote Link to comment Share on other sites More sharing options...
KGehrels Posted March 10 Author Share Posted March 10 Can you please post the link that you are referring to. I used some code that was posted on this site to get all of the variables for a dimension (I forget who posted so I can't give credit where it's due) and double checked that I used all tolerance related variables. If there is another variable it is one that isn't obvious. Or this is one of those things where there are 4 different ways to make it work but each of those can only be used in specific circumstances and the only way to know is to stumble across it or be told (sort of like setting the colour of various object to "bylayer", all of these work at some point: bylayer, -1, 0, 256). Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 10 Share Posted March 10 Thought it had pasted the link: Quote Link to comment Share on other sites More sharing options...
KGehrels Posted March 11 Author Share Posted March 11 Those all look like dimstyle codes. I'm not looking to change the dimstyle, just maintain some dimension overrides. I tried looking through these codes but couldn't find anything that isn't controlled by the commands that I've already put in the code. https://74mph.com/faq/FAQ00066.html Quote Link to comment Share on other sites More sharing options...
KGehrels Posted March 12 Author Share Posted March 12 Any other ideas? Quote Link to comment Share on other sites More sharing options...
KGehrels Posted March 15 Author Share Posted March 15 Is there a way of applying dimstyle overrides to dimensions? I found this thread which contains great information from @Lee Mac but I can't get the same idea to work in my code. Change a system variable for a single Dim entity ... (theswamp.org) My code is: (defun LinearCollate (stylescale dimlist stylename / dimscale txtovr txtpre txtsuf tdisp thscale tjust tllimit tprec tsuplz tsuptz tsupzf tsupzi tulimit) (vl-load-com) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-activedocument acadObj)) (Foreach dim dimlist (setq dimscale (vlax-get-property dim "LinearScaleFactor")) ; Find the scale of each dimension ; Get all tolerance properties (setq txtovr (vlax-get-property dim "TextOverride")) (setq txtpre (vlax-get-property dim "TextPrefix")) (setq txtsuf (vlax-get-property dim "TextSuffix")) (setq tdisp (vlax-get-property dim "ToleranceDisplay")) (setq thscale (vlax-get-property dim "ToleranceHeightScale")) (setq tjust (vlax-get-property dim "ToleranceJustification")) (setq tllimit (vlax-get-property dim "ToleranceLowerLimit")) (setq tprec (vlax-get-property dim "TolerancePrecision")) (setq tsuplz (vlax-get-property dim "ToleranceSuppressLeadingZeros")) (setq tsuptz (vlax-get-property dim "ToleranceSuppressTrailingZeros")) (setq tsupzf (vlax-get-property dim "ToleranceSuppressZeroFeet")) (setq tsupzi (vlax-get-property dim "ToleranceSuppressZeroInches")) (setq tulimit (vlax-get-property dim "ToleranceUpperLimit")) ;DIMLIM, 0=Symmetrical, 1=Bilateral, I think that this is a system variable (if (equal dimscale stylescale 0.1) ; Check if the style scale matches the dimension scale (progn ; If true then: (if (equal tdsip 2) ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 72) (1070 . 1) (1002 . "}") ) ) ; end if (vlax-put-property dim "StyleName" stylename) ; Assign the dimstyle to the dimension ;Apply all tolerance properties from above (vlax-put-property dim "TextOverride" txtovr) (vlax-put-property dim "TextPrefix" txtpre) (vlax-put-property dim "TextSuffix" txtsuf) (vlax-put-property dim "ToleranceDisplay" tdisp) (vlax-put-property dim "ToleranceHeightScale" thscale) (vlax-put-property dim "ToleranceJustification" tjust) (vlax-put-property dim "ToleranceLowerLimit" tllimit) (vlax-put-property dim "TolerancePrecision" tprec) (vlax-put-property dim "ToleranceSuppressLeadingZeros" tsuplz) (vlax-put-property dim "ToleranceSuppressTrailingZeros" tsuptz) (vlax-put-property dim "ToleranceSuppressZeroFeet" tsupzf) (vlax-put-property dim "ToleranceSuppressZeroInches" tsupzi) (vlax-put-property dim "ToleranceUpperLimit" tulimit) ) ; End progn ) ; End if ) ; End Foreach ) ; End LinearCollate When I try this I get this error: bad function in expression: ("ACAD" (1000 . "DSTYLE") (1002 . "{") (1070 . 72) (1070 . 1) (1002 . "}")) What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
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.