paulmcz Posted March 30, 2015 Share Posted March 30, 2015 I need to overwrite the dimension text for several dimensions in one shot but the overwrite has to be different for radial or angular or linear dimension. How do I find out what type of dimension was selected? How to iterate through several (assoc 100) to get to the right information? What is the best technique for that? There is several instances of (assoc 100) in each dxf group code for dimension. Sometimes the info I am looking for (radial, aligned, rotated etc) is in the third and the other time in forth instance of (assoc 100). Here I go through the first two (assoc 100) to get the right value from the third one. How do you guys do that? Thanks. (setq d (1- sl) n (ssname ss d) ; ss = selection set obtained with ssget e1 (entget n) q (cdr (member (assoc 100 e1) e1)); step over the first assoc 100 q (cdr (member (assoc 100 q) q)) ; step over the second assoc 100 q (cdr (assoc 100 q)) ; get the info here ) Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 30, 2015 Share Posted March 30, 2015 hi paulmcz , perhaps VLisp approach is what you are looking for? ([color="blue"]vla-get-Objectname[/color] (vlax-ename->vla-object entity)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2015 Share Posted March 30, 2015 If a Vanilla solution is required, I would test the value of DXF Group 70, e.g.: to test for a radial dimension: (= 4 (logand (cdr (assoc 70 (entget <dim>))) (~ 224))) Quote Link to comment Share on other sites More sharing options...
paulmcz Posted March 30, 2015 Author Share Posted March 30, 2015 hi paulmcz , perhaps VLisp approach is what you are looking for? ([color="blue"]vla-get-Objectname[/color] (vlax-ename->vla-object entity)) Thanks hanhphuc. Unfortunately, I don't know enough about Vlisp to try your approach. Quote Link to comment Share on other sites More sharing options...
paulmcz Posted March 30, 2015 Author Share Posted March 30, 2015 If a Vanilla solution is required, I would test the value of DXF Group 70, e.g.: to test for a radial dimension: (= 4 (logand (cdr (assoc 70 (entget <dim>))) (~ 224))) Hi Lee, your solution works perfect, as always. Thank you. I just wish I'd know what is going on here. I don't know the arithmetic behind logand function. How can this (logand 164 -225) return 4 is beyond me. Thanks Lee. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2015 Share Posted March 30, 2015 (edited) Hi Lee, your solution works perfect, as always. Thank you. Excellent, you're most welcome Paul I just wish I'd know what is going on here. I don't know the arithmetic behind logand function. How can this (logand 164 -225) return 4 is beyond me. To help with your understanding, rather than looking at it from an arithmetic perspective (i.e. base 10), try to visualise it in binary (base 2) to see how the bitwise operations (logand / logior / boole etc.) affect each bit. DXF group 70 is usually always a bit-coded value, however, the DXF 70 group for dimensions is slightly odd in that values 0-6 are consecutive integers, and values 32 onwards are bit-codes. Hence, although Radial dimensions have a DXF group 70 code of 4, you cannot simply use the following to test whether a dimension is Radial (as you might with other DXF group 70 codes): (= 4 (logand 4 (cdr (assoc 70 (entget <dim>))))) Since, this will also return T for Ordinate dimensions (as 6=2+4). Therefore, rather than performing an AND operation with a specific bit (i.e. bit 4 in this case), the logand expression in my example is masking bits 32-128, such that the bitwise AND operation will match any other bits that are set. As an example, consider an X-type Ordinate dimension that the user has repositioned, with DXF group 70 equal to 198 [noparse](6+64+128)[/noparse]. The binary representation of 198 as a 32-bit signed integer would be: 198 = 00000000 00000000 00000000 11000110 Performing a bitwise NOT on 224 [noparse](=32+64+128)[/noparse] would be represented in binary as: (~ 224) = 11111111 11111111 11111111 00011111 Now, performing a bitwise AND operation against these two binary representations effectively masks the 32, 64 & 128 bits, leaving us with any remaining bits that are set: 00000000 00000000 00000000 11000110 AND 11111111 11111111 11111111 00011111 --------------------------------------- 00000000 00000000 00000000 00000110 = 6 I hope this is clearer. Lee Edited March 30, 2015 by Lee Mac Quote Link to comment Share on other sites More sharing options...
paulmcz Posted March 30, 2015 Author Share Posted March 30, 2015 Thank you very much Lee. I really appreciate this. Yes, it is slowly clearing up for me. I am starting to see the world in a completely different way now. Paul. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2015 Share Posted March 30, 2015 Excellent, I'm pleased the explanation was clear I've just corrected a couple of typos (the 225 should have been 224). Lee Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 30, 2015 Share Posted March 30, 2015 ...DXF group 70 is usually always a bit-coded value, however, the DXF 70 group for dimensions is slightly odd in that values 0-6 are consecutive integers, and values 32 onwards are bit-codes. Hence, although Radial dimensions have a DXF group 70 code of 4, you cannot simply use the following to test whether a dimension is Radial (as you might with other DXF group 70 codes): (= 4 (logand 4 (cdr (assoc 70 (entget <dim>))))) Since, this will also return T for Ordinate dimensions (as 6=2+4). Lee Nice Lee for the clarification. as i expected you would give us very useful information. noted & appreciated i must admit your dxf suggestion is very useful especially in ssget filtering, (ssget (mapcar 'cons '(0 -4 70) (list "DIMENSION" [color="red"]"&="[/color] ([color="blue"]boole[/color] [color="green"]1[/color] 198 ([color="blue"]~[/color] 224)))))[color="green"]; logand[/color] This topic reminds me about recent thread dxf 70 with Bitwise Masked Equals operator "&=" again thank you Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2015 Share Posted March 30, 2015 Nice Lee for the clarification. as i expected you would give us very useful information. noted & appreciated You're welcome hanhphuc, I'm happy to help i must admit your dxf suggestion is very useful especially in ssget filtering, (ssget (mapcar 'cons '(0 -4 70) (list "DIMENSION" [color=red]"&="[/color] ([color=blue]boole[/color] [color=green]1[/color] 198 ([color=blue]~[/color] 224)))))[color=green]; logand[/color] This topic reminds me about recent thread dxf 70 with Bitwise Masked Equals operator "&=" A good idea, but unfortunately I don't think it can be that simple - for example, consider that you wanted to construct an ssget filter to permit only Radial dimensions. You might use a filter such as: (ssget '((0 . "DIMENSION") (-4 . "&=") (70 . 4))) However, this would also match Ordinate dimensions (since 6=2+4) - therefore, a bit-coded filter cannot be used in this case. My solution to this problem is to use a function such as the following in order to construct the appropriate filter: [color=GREEN];; Dimension Selection Filter List - Lee Mac[/color] [color=GREEN];; Constructs an appropriate filter list for the given dimension types[/color] [color=GREEN];; lst - [lst] List of DXF Group 70 dimension types (0-6)[/color] [color=GREEN];; e.g. Rotated & Aligned Dimensions: (LM:dimfilter '(0 1))[/color] ([color=BLUE]defun[/color] LM:dimfilter ( lst ) ( ([color=BLUE]lambda[/color] ( bit ) ([color=BLUE]append[/color] '((0 . [color=MAROON]"*DIMENSION"[/color]) (-4 . [color=MAROON]"<OR"[/color])) ([color=BLUE]apply[/color] '[color=BLUE]append[/color] ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( typ ) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]cons[/color] 70 ([color=BLUE]+[/color] typ x))) bit)) lst)) '((-4 . [color=MAROON]"OR>"[/color])) ) ) (LM:bitcombinations '(32 64 128)) ) ) [color=GREEN];; Bit Combinations - Lee Mac[/color] [color=GREEN];; Returns all combinations for a given set of bit-codes[/color] ([color=BLUE]defun[/color] LM:bitcombinations ( l [color=BLUE]/[/color] foo bar ) ([color=BLUE]defun[/color] foo ( l r ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] l ([color=BLUE]<[/color] 1 r)) ([color=BLUE]append[/color] ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]+[/color] ([color=BLUE]car[/color] l) x)) (foo ([color=BLUE]cdr[/color] l) ([color=BLUE]1-[/color] r))) (foo ([color=BLUE]cdr[/color] l) r)) l ) ) ([color=BLUE]defun[/color] bar ( l r ) ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 r) ([color=BLUE]append[/color] (bar l ([color=BLUE]1-[/color] r)) (foo l r))) ) ([color=BLUE]cons[/color] 0 (bar l ([color=BLUE]length[/color] l))) ) The above could be used in the following way to select only Radial dimensions: ([color=BLUE]defun[/color] c:test ( ) ([color=BLUE]sssetfirst[/color] [color=BLUE]nil[/color] ([color=BLUE]ssget[/color] (LM:dimfilter '(4)))) ) Lee 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.