Lee Mac Posted February 23, 2011 Share Posted February 23, 2011 Yeah, I was standing in front of the urinal and realized what you must have done. lol :lol: Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 24, 2011 Author Share Posted February 24, 2011 I'd probably write it like this: (defun c:test ( / _move d ss l lst ) (vl-load-com) (defun _move ( obj dist ) (vla-move (vla-copy obj) (vlax-3D-point '(0. 0. 0.)) (vlax-3D-point (list 0. dist 0.))) ) (if (ssget "_:L") (progn (vlax-for obj (setq d 0. ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (_move obj (cond ( (cdr (assoc (setq l (vla-get-layer obj)) lst)) ) ( (setq lst (cons (cons l (setq d (- d 50.))) lst)) d ) ) ) ) (vla-delete ss) ) ) (princ) ) Lee Mac you right, the code work fine but i need user pick the point for the new location i really don't about Vlisp, i'm still using Autolisp as beginner Tq Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 24, 2011 Author Share Posted February 24, 2011 (edited) I think his problem is in his first ssget selection, he's selecting objects on multiple layers. The first time for each layer is fine, but if it's repeated, all hell breaks loose. Is this what you are after? (defun c:TEst (/ q ss pt i layer lst) (if (and (setq q -50. ss (ssget "_:L") ) (setq pt (getpoint "\nSpecify base point: ")) ) (repeat (setq i (sslength ss)) (if (not (member (setq layer (cdr (assoc 8 (entget (ssname ss (setq i (1- i))))))) lst)) (progn (setq lst (cons layer lst)) (command "_.copy" (ssget "_X" (list (cons 8 layer) (cons 410 (getvar 'ctab)))) "" "_non" (polar pt (* 1.5 pi) (setq q (+ q 50.))) "" ) ) ) ) ) (princ) ) yes thats i want, any problem after i test it, i'll let your know here problem is, when user select the object target 2nd time, all layer copy duplicate to new location, pls test it... what i mean TQ Edited February 24, 2011 by nalsur8 after testing few times..... Quote Link to comment Share on other sites More sharing options...
pBe Posted February 24, 2011 Share Posted February 24, 2011 Well there you have it Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 24, 2011 Author Share Posted February 24, 2011 Well there you have it coding from LeeMac, no user input for location place actualy i want use that code, any ideal to add user input? Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 24, 2011 Author Share Posted February 24, 2011 other issue, my layer have 2 type, 01,02,03... and so on.... is object and 01D,02D,03D... and so on is for DIMENSION layer, all dimension layer have "D" behind number, so i want the layer 01 and 01D is are same location (overlap), with the current coding is separated all layer individual Quote Link to comment Share on other sites More sharing options...
alanjt Posted February 24, 2011 Share Posted February 24, 2011 Yeah, the secondary ssget "_X" is a terrible way to go about it. I was sick yesterday and my brain wasn't functioning. Here's Lee's slightly modified. (defun c:test (/ _move p d ss l lst) (vl-load-com) (defun _move (obj p dist) (vla-move (vla-copy obj) (vlax-3D-point p) (vlax-3D-point (polar p (* 1.5 pi) dist))) ) (if (and (ssget "_:L") (setq p (getpoint "\nSpecify base point: "))) (progn (vlax-for obj (setq d 0. p (trans p 1 0) ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))) ) (_move obj p (cond ((cdr (assoc (setq l (vla-get-layer obj)) lst))) ((setq lst (cons (cons l (setq d (+ d 50.))) lst)) d) ) ) ) (vla-delete ss) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 24, 2011 Share Posted February 24, 2011 Cheers Alan - I was in no mood to code all those requests... Quote Link to comment Share on other sites More sharing options...
alanjt Posted February 24, 2011 Share Posted February 24, 2011 Cheers Alan - I was in no mood to code all those requests... OH, I didn't tackle that mess and I'm not going to either. If he wants particular layers overlapped, he's got to filter them himself. I just altered your code to account for user picked point. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 24, 2011 Share Posted February 24, 2011 OH, I didn't tackle that mess and I'm not going to either. If he wants particular layers overlapped, he's got to filter them himself. Quote Link to comment Share on other sites More sharing options...
alanjt Posted February 24, 2011 Share Posted February 24, 2011 LoL, after actually reading his filtering request, you could accomplish it by adding these two lines: ((cdr (assoc (vl-string-right-trim "D" l) lst))) ((cdr (assoc (strcat l "D") lst))) Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 25, 2011 Author Share Posted February 25, 2011 Yeah, the secondary ssget "_X" is a terrible way to go about it. I was sick yesterday and my brain wasn't functioning. Here's Lee's slightly modified. (defun c:test (/ _move p d ss l lst) (vl-load-com) (defun _move (obj p dist) (vla-move (vla-copy obj) (vlax-3D-point p) (vlax-3D-point (polar p (* 1.5 pi) dist))) ) (if (and (ssget "_:L") (setq p (getpoint "\nSpecify base point: "))) (progn (vlax-for obj (setq d 0. p (trans p 1 0) ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))) ) (_move obj p (cond ((cdr (assoc (setq l (vla-get-layer obj)) lst))) ((setq lst (cons (cons l (setq d (+ d 50.))) lst)) d) ) ) ) (vla-delete ss) ) ) (princ) ) after testing the code, user input (setq p (getpoint "\nSpecify base point: ") not related other word nothing the new location it's same w/out (setq p (getpoint "\nSpecify base point: ") Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 25, 2011 Share Posted February 25, 2011 (defun c:test ( / _move d ss l lst ) (vl-load-com) (defun _move ( obj p q dist ) (vla-move (setq obj (vla-copy obj)) (vlax-3D-point p) (vlax-3D-point q)) (vla-move obj (vlax-3D-point '(0. 0. 0.)) (vlax-3D-point (list 0. dist 0.))) ) (if (and (ssget "_:L") (setq p1 (getpoint "\nBase Point: ")) (setq p2 (getpoint "\nDesired Location: " p1)) (setq p1 (trans p1 1 0) p2 (trans p2 1 0)) ) (progn (vlax-for obj (setq d 50. ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (_move obj p1 p2 (cond ( (cdr (assoc (setq l (vla-get-layer obj)) lst)) ) ( (setq lst (cons (cons l (setq d (- d 50.))) lst)) d ) ) ) ) (vla-delete ss) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 25, 2011 Author Share Posted February 25, 2011 Yeah, the secondary ssget "_X" is a terrible way to go about it. I was sick yesterday and my brain wasn't functioning. Here's Lee's slightly modified. (defun c:test (/ _move p d ss l lst) (vl-load-com) (defun _move (obj p dist) (vla-move (vla-copy obj) (vlax-3D-point p) (vlax-3D-point (polar p (* 1.5 pi) dist))) ) (if (and (ssget "_:L") (setq p (getpoint "\nSpecify base point: "))) (progn (vlax-for obj (setq d 0. p (trans p 1 0) ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))) ) (_move obj p (cond ((cdr (assoc (setq l (vla-get-layer obj)) lst))) ((setq lst (cons (cons l (setq d (+ d 50.))) lst)) d) ) ) ) (vla-delete ss) ) ) (princ) ) after testing the code, the result it's same with LM code w/o (setq p (getpoint "\nSpecify base point: ") coding you was add (setq p (getpoint "\nSpecify base point: ") it's unrelated other word nothing do just asking user to get point the result still same.. did you test it? Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 25, 2011 Author Share Posted February 25, 2011 (defun c:test ( / _move d ss l lst ) (vl-load-com) (defun _move ( obj p q dist ) (vla-move (setq obj (vla-copy obj)) (vlax-3D-point p) (vlax-3D-point q)) (vla-move obj (vlax-3D-point '(0. 0. 0.)) (vlax-3D-point (list 0. dist 0.))) ) (if (and (ssget "_:L") (setq p1 (getpoint "\nBase Point: ")) (setq p2 (getpoint "\nDesired Location: " p1)) (setq p1 (trans p1 1 0) p2 (trans p2 1 0)) ) (progn (vlax-for obj (setq d 50. ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (_move obj p1 p2 (cond ( (cdr (assoc (setq l (vla-get-layer obj)) lst)) ) ( (setq lst (cons (cons l (setq d (- d 50.))) lst)) d ) ) ) ) (vla-delete ss) ) ) (princ) ) YES.. now all ok after i adding code by alanjt ((cdr (assoc (vl-string-right-trim "D" l) lst))) ((cdr (assoc (strcat l "D") lst))) the problem now is, the layer is not sorting, sorting like this Top is layer=01,01D 2nd layer=02,02D and so on... Quote Link to comment Share on other sites More sharing options...
alanjt Posted February 25, 2011 Share Posted February 25, 2011 YES.. now all ok after i adding code by alanjt((cdr (assoc (vl-string-right-trim "D" l) lst))) ((cdr (assoc (strcat l "D") lst))) the problem now is, the layer is not sorting, sorting like this Top is layer=01,01D 2nd layer=02,02D and so on... So, sort the selection set by layer and copy them down. I think it's time you give it a whirl. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 25, 2011 Share Posted February 25, 2011 I'm tired of his attitude - I'm done with this thread. Quote Link to comment Share on other sites More sharing options...
pBe Posted February 25, 2011 Share Posted February 25, 2011 I'm tired of his attitude - I'm done with this thread. x2 Tired of reading the his replies as well Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 25, 2011 Author Share Posted February 25, 2011 I'm tired of his attitude - I'm done with this thread. you a give-up man..., sorry i say that pls refer to my 1st page of thread.. if you not understand my English, i'm can accept i'm not a good in english but i try to do my best to explain what actually i need from yours about little coding this code is for detailing by layer name the layer must all open/show, user select the all layer and give the place point, my problem with this code is, the layer is not sort by number (my layer is 01 02 03 04 and so on) and sometime double copy with same layer name. any solution pls tqthankz to all to teached me and solve the problem.. but actually not yet solve assume that this problem has been completed, I'll close this thread "if people want to learn, learn from beginning A-Z not jumping³" Quote Link to comment Share on other sites More sharing options...
nalsur8 Posted February 25, 2011 Author Share Posted February 25, 2011 x2 Tired of reading the his replies as well i'm not good in english.... thankz 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.