Jump to content

copy layer and sort, sometime duble copy


nalsur8

Recommended Posts

  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

  • nalsur8

    15

  • pBe

    11

  • Lee Mac

    8

  • alanjt

    7

Top Posters In This Topic

Posted Images

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)
)

 

:D 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 :roll: as beginner

 

Tq

Link to comment
Share on other sites

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 by nalsur8
after testing few times.....
Link to comment
Share on other sites

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

dimc0py1.jpg

dimc0py2.jpg

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

Cheers Alan - I was in no mood to code all those requests... :ouch:

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.

Link to comment
Share on other sites

:thumbsup:

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)))

Link to comment
Share on other sites

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: ")

Link to comment
Share on other sites

(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)
)

Link to comment
Share on other sites

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? dimc0py3.jpg

Link to comment
Share on other sites

(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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 tq
thankz 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³"

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...