Align multiple blocks to 3Dpolyline lisp

Align multiple blocks to 3Dpolyline lisp

yu85.info
Collaborator Collaborator
540 Views
7 Replies
Message 1 of 8

Align multiple blocks to 3Dpolyline lisp

yu85.info
Collaborator
Collaborator

Hi, I have this drawing attached with many blocks. Is there a lisp to align all of them to the 3D polyline they are on it? 

I founded some lisp in the web but none of them seems to work on this case of 3D polyline.

Thanks very much in advance

 

0 Likes
Accepted solutions (2)
541 Views
7 Replies
Replies (7)
Message 2 of 8

-didier-
Advisor
Advisor

Bonjour @yu85.info 

 

These are blocks of topographical points, so I understand that you have to align the attribute not the block itself, right?

Snag_62b47e8e.png

Amicalement

 

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

Message 3 of 8

yu85.info
Collaborator
Collaborator

Yes sir you are correct

0 Likes
Message 4 of 8

-didier-
Advisor
Advisor
Accepted solution

Bonjour @yu85.info 

 

Here is a program for you.

It only processes one polyline at a time because I find that more efficient, we only process what we need.
If necessary, improvement is possible.

 

Amicalement

 

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

Message 5 of 8

yu85.info
Collaborator
Collaborator

Dear sir, thank you for your hard work. Sorry for my rudeness but is it  possible to change it so it will work on multiple 3Dpolylines?

 

0 Likes
Message 6 of 8

marko_ribar
Advisor
Advisor
Accepted solution

You mean like this... Untested, though...

(defun c:aliblopols ( / LM:MakeReadable s i pol ss loop n lstpar blo p dir lstpar )

  (defun LM:MakeReadable ( a )
    ;; © Lee Mac 2010
    (
      (lambda ( a )
        (cond
          ( (and (> a (/ pi 2)) (<= a pi))
            (- a pi)
          )
          ( (and (> a pi) (<= a (/ (* 3 pi) 2)))
            (+ a pi)
          )
          ( t a )
        )
      )
      (rem a (* 2 pi))
    )
  )

  (prompt "\nSelect polyline entities on which you want to make block alignments readable...")
  (setq s (ssget (list (cons 0 "*POLYLINE"))))
  (repeat (setq i (sslength s))
    (setq pol (ssname s (setq i (1- i))))
    (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 "M1502_P"))))
    (if (= (logand 1 (cdr (assoc 70 (entget pol)))) 1)
      (setq loop (fix (vlax-curve-getEndParam pol)))
      (setq loop (1+ (fix (vlax-curve-getEndParam pol))))
    )
    (setq n -1)
    (repeat loop
      (setq lstpar (cons (vlax-curve-getpointatparam pol (setq n (1+ n))) lstpar))
    )
    (setq n -1)
    (repeat (sslength ss)
      (setq blo (ssname ss (setq n (1+ n))))
      (setq p (cdr (assoc 10 (entget blo))))
      (if (member p lstpar)
        (progn                
          (setq dir (LM:MakeReadable (angle (list 0.0 0.0) (vlax-curve-getFirstDeriv pol (vlax-curve-getparamatpoint pol p)))))
          (vlax-put (vlax-ename->vla-object blo) (quote rotation) dir)
        )
      )
    )
(setq lstpar nil) ) (princ) ) (prompt "\nType ALIBLOPOLS to run the topo point alignment command on a polyline(s)\n") (princ)

 

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 7 of 8

-didier-
Advisor
Advisor

Bonjour @marko_ribar 

 

Thank you for your intervention, I had not seen the request, wait to see if @yu85.info is satisfied.

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

Message 8 of 8

yu85.info
Collaborator
Collaborator

Amazing! 

Thank you both @-didier- @marko_ribar 

0 Likes