jamami Posted August 4 Posted August 4 I have developed the attached dynamic block which positions nested blocks according to the distance value set in a block properties table. To avoid text mirroring of the nested block labels I have used attributes and added a flip action. This all works well until I try and change the length after a flip. It appears the xpos value in the block properties table is applied as positive despite the flip state. I have tried changing the point parameters to stretch parameters but have similar problems, especially when rotating the assembly to different angles. I was hoping something as simple as adding a formulae into the block properties table ie dist*flipstate would work but there doesn't seem to be anyway to do this. Is there a way to solve this? jam3.dwg Quote
SLW210 Posted August 5 Posted August 5 No time for me to look at your blocks, but have you looked into constraints? I have some dynamic block with lots of actions and even constrained if you do things in a weird order they can get a little off. So make sure length is set before the flip action. Probably could constrain them more or different. I don't know. I'll see what time I have today, but I am at work for a shorter time today than usual. Quote
jamami Posted August 5 Author Posted August 5 Problem is we cannot always set the length prior to flip as we need to find the right size after the flip. I am trying a few different methods hopefully I can get this to work Quote
BIGAL Posted August 6 Posted August 6 I will add the set property later but this is front end as an example, just copy all the code and paste to command line . (defun wow ( / fo ) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line " dyntruss : dialog { " fo) (write-line " label = \"Enter Values\" ; " fo) (write-line " : column { " fo) (write-line " width =25; " fo) (write-line " spacer_1 ; " fo) (write-line " : edit_box { " fo) (write-line " key = \"key1\" ; " fo) (write-line " label = \"Length \" ; " fo) (write-line " edit_width = 5; " fo) (write-line " edit_limit = 4; " fo) (write-line " is_enabled = true ; " fo) (write-line " allow_accept=true ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : edit_box { " fo) (write-line " key = \"key2\" ; " fo) (write-line " label = \"Angle \" ; " fo) (write-line " edit_width = 5; " fo) (write-line " edit_limit = 4; " fo) (write-line " is_enabled = true ; " fo) (write-line " allow_accept=true ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : radio_row { " fo) (write-line " : radio_button { " fo) (write-line " key = \"Rb1\" ; " fo) (write-line " label = \"Flipped\" ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : radio_button { " fo) (write-line " key = \"Rb2\" ; " fo) (write-line " label = \"No Flip\" ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " ok_cancel ; " fo) (write-line " } " fo) (write-line " } " fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "dyntruss" dcl_id) ) (exit) ) (set_tile "key1" "10") (set_tile "key2" "0") (set_tile "Rb1" "1") (action_tile "accept" "(setq val1 (atof (get_tile \"key1\")))(setq val2 (atof (get_tile \"key2\")))(setq val3 (get_tile \"Rb1\"))(done_dialog)") (action_tile "cancel" "(setq cancel \"yes\")(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (if (= val3 "1")(setq visibilty "Flip")(setq visibilty "Noflip")) (princ) ) (wow) Quote
BIGAL Posted Sunday at 02:06 AM Posted Sunday at 02:06 AM I still think its easier to copy/array the dynamic block just setting the correct visibility state so that would be 2 3 4 5 6 only. No working out the dynamic pattern. Angle is not a problem. This is all your sizes up to length of 50 the pattern is length, how many 6s 5s 4s 3s 2s could do way more you can also change the way a length is made example 10 is 2x5 or a 6+4 ((51 8 0 0 1 0) (50 8 0 0 0 1) (49 7 1 0 0 1) (48 8 0 0 0 0) (47 7 1 0 0 0) (46 7 0 1 0 0) (45 7 0 0 1 0) (44 7 0 0 0 1) (43 6 1 0 0 1) (42 7 0 0 0 0) (41 6 1 0 0 0) (40 6 0 1 0 0) (39 6 0 0 1 0) (38 6 0 0 0 1) (37 5 1 0 0 1) (36 6 0 0 0 0) (35 5 1 0 0 0) (34 5 0 1 0 0) (33 5 0 0 1 0) (32 5 0 0 0 1) (31 4 1 0 0 1) (30 5 0 0 0 0) (29 4 1 0 0 0) (28 4 0 1 0 0) (27 4 0 0 1 0) (26 4 0 0 0 1) (25 3 1 0 0 1) (24 4 0 0 0 0) (23 3 1 0 0 0) (22 3 0 1 0 0) (21 3 0 0 1 0) (20 3 0 0 0 1) (19 2 1 0 0 1) (18 3 0 0 0 0) (17 2 1 0 0 0) (16 2 0 1 0 0) (15 2 0 0 1 0) (14 2 0 0 0 1) (13 1 1 0 0 1) (12 2 0 0 0 0) (11 1 1 0 0 0) (10 1 0 1 0 0) (9 1 0 0 1 0) (8 1 0 0 0 1) (7 0 1 0 0 1) (6 1 0 0 0 0) (5 0 1 0 0 0) (4 0 0 1 0 0) (3 0 0 0 1 0) (2 0 0 0 0 1)) Quote
jamami Posted Sunday at 06:11 AM Author Posted Sunday at 06:11 AM Thanks for this. How can the large size array be used ? does it need to be passed to a function ? Quote
BIGAL Posted Monday at 01:21 AM Posted Monday at 01:21 AM The idea is that you could break down the task to individual blocks and either have the five blocks or a dynamic block that sets the correct truss size visibilty but a say 10m would be 5 individual blocks, much easier to manipulate than have some 50 visibility states. Ok so just read the length match sizes if a size is 0 then don't add it to the draw trusses. I have also thought could save the build order in a different pattern say a 26m would be (26 "2x6" "1x2" "2x6") so the 2m truss would be in the middle. A 10 would be just (10 "2x5") its easy to convert the number of in a repeat. Re angle just insert the blocks and rotate all of them in one go. Yes needs new code which time permitting will do. Quote
jamami Posted Monday at 06:27 AM Author Posted Monday at 06:27 AM I think I am on top of this now, thank you for all you insightful comments . No need for additional code at this stage . Quote
BIGAL Posted 1 hour ago Posted 1 hour ago i had some time so put together something, once I finished I realised could have been made simpler by just inserting the single blocks rather than using the dynamic block. Any way have a look at this. ; https://www.cadtutor.net/forum/topic/98637-how-to-stop-flip-action-reversing-offsets-in-dynamic-block/ ; See below (defun c:dyntruss ( / x truss num) (if (not LM:setdynpropvalue)(load "Dynamic block get-put Lee-mac")) ;; Set Dynamic Block Property Value - Lee Mac ;; Modifies the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) ;; val - [any] New value for property ;; Returns: [any] New value if successful, else nil (defun LM:setdynpropvalue ( blk prp val ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (progn (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x)))) (cond (val) (t)) ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) ; (LM:setdynpropvalue obj "Flip state1" flip) ; (LM:setdynpropvalue obj "Length" val1) ; (LM:SetVisibilityState obj "3+4+6") (defun trussdcl ( / fo ) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line " dyntruss : dialog { " fo) (write-line " label = \"Enter Values\" ; " fo) (write-line " : column { " fo) (write-line " width =25; " fo) (write-line " spacer_1 ; " fo) (write-line " : edit_box { " fo) (write-line " key = \"key1\" ; " fo) (write-line " label = \"Length \" ; " fo) (write-line " edit_width = 5; " fo) (write-line " edit_limit = 4; " fo) (write-line " is_enabled = true ; " fo) (write-line " allow_accept=true ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : edit_box { " fo) (write-line " key = \"key2\" ; " fo) (write-line " label = \"Angle \" ; " fo) (write-line " edit_width = 5; " fo) (write-line " edit_limit = 4; " fo) (write-line " is_enabled = true ; " fo) (write-line " allow_accept=true ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : radio_row { " fo) (write-line " : radio_button { " fo) (write-line " key = \"Rb1\" ; " fo) (write-line " label = \"Flipped\" ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " : radio_button { " fo) (write-line " key = \"Rb2\" ; " fo) (write-line " label = \"No Flip\" ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " } " fo) (write-line " spacer_1 ; " fo) (write-line " ok_cancel ; " fo) (write-line " } " fo) (write-line " } " fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "dyntruss" dcl_id) ) (exit) ) (set_tile "key1" "10") (set_tile "key2" "0") (set_tile "Rb2" "1") (action_tile "accept" "(setq val1 (atof (get_tile \"key1\")))(setq val2 (atof (get_tile \"key2\")))(setq val3 (atoi (get_tile \"Rb1\")))(done_dialog)") (action_tile "cancel" "(setq cancel \"yes\")(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (princ) ) ;;;;;;;;;;;; starts here ;;;;;;;;;;;;;;; (setq oldsnap (getvar 'Osmode)) (setvar 'osmode 0) (trussdcl) (setq truss-size (list '(51 8 0 0 1 0) '(50 8 0 0 0 1) '(49 7 1 0 0 1) '(48 8 0 0 0 0) '(47 7 1 0 0 0) '(46 7 0 1 0 0) '(45 7 0 0 1 0) '(44 7 0 0 0 1) '(43 6 1 0 0 1) '(42 7 0 0 0 0) '(41 6 1 0 0 0) '(40 6 0 1 0 0) '(39 6 0 0 1 0) '(38 6 0 0 0 1) '(37 5 1 0 0 1) '(36 6 0 0 0 0) '(35 5 1 0 0 0) '(34 5 0 1 0 0) '(33 5 0 0 1 0) '(32 5 0 0 0 1) '(31 4 1 0 0 1) '(30 5 0 0 0 0) '(29 4 1 0 0 0) '(28 4 0 1 0 0) '(27 4 0 0 1 0) '(26 4 0 0 0 1) '(25 3 1 0 0 1) '(24 4 0 0 0 0) '(23 3 1 0 0 0) '(22 3 0 1 0 0) '(21 3 0 0 1 0) '(20 3 0 0 0 1) '(19 2 1 0 0 1) '(18 3 0 0 0 0) '(17 2 1 0 0 0) '(16 2 0 1 0 0) '(15 2 0 0 1 0) '(14 2 0 0 0 1) '(13 1 1 0 0 1) '(12 2 0 0 0 0) '(11 1 1 0 0 0) '(10 1 0 1 0 0) '(9 1 0 0 1 0) '(8 1 0 0 0 1) '(7 0 1 0 0 1) '(6 1 0 0 0 0) '(5 0 1 0 0 0) '(4 0 0 1 0 0) '(3 0 0 0 1 0) '(2 0 0 0 0 1)) ) (setq ss nil) (setq ss (ssadd)) (setq ang (* pi (/ val2 180.0))) (foreach val truss-size (if (= (car val) val1) (setq sizes val) ) ) (setq pt (getpoint "\nPick point for truss ")) (setq basept pt) (if (= val3 0) (setq flip "Not flipped") (setq flip "Flipped") ) (setq k 0 truss 7) (repeat 5 (setq k (1+ k) truss (1- truss)) (setq num (nth k sizes)) (if (= num 0) (princ (strcat "\nNo " (rtos truss 2 0) "m ")) (progn (repeat num (command "-insert" "d-d78" "s" 1 pt 0) (setq obj (vlax-ename->vla-object (entlast))) (LM:setdynpropvalue obj "Beam viz" (rtos truss 2 0)) (LM:setdynpropvalue obj "Angle1" ang) (setq ss (ssadd (entlast))) (setq pt (polar pt ang (* truss 1000.0))) ) ) ) ) (setvar 'osmode oldsnap) (princ) ) (c:dyntruss) https://www.lee-mac.com/ssget.html 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.