Author Topic: Problem with attributed blocks...  (Read 1541 times)

0 Members and 1 Guest are viewing this topic.

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Problem with attributed blocks...
« on: August 15, 2016, 01:56:27 AM »
Hi All!

I find this routine on this forum

http://forums.autodesk.com/t5/visual-lisp-autolisp​-and-general/align-all-objects-along-one-x-y-z-axi​...

and I think it's very useful, but I have a problem when I want to align attributed blocks along one X/Y/Z axis of a reference point.. attributes remains on previous place

Can you fix this problem?

Thank you anyway

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Problem with attributed blocks...
« Reply #1 on: August 15, 2016, 02:38:26 AM »
The link isn't good...
Please recheck it...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube


ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Problem with attributed blocks...
« Reply #3 on: August 15, 2016, 05:38:23 AM »
Here try this, but make sure it's current WCS...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:AxAlign ( / ax co ss i ed pt e ptt )
  2.  
  3.   (initget "X Y Z")
  4.   (setq ax
  5.     (cond
  6.       ( (getkword "Which coordinate make the same [X/Y/Z] <Y>: ")
  7.       )
  8.       ("Y")
  9.     )
  10.   )
  11.   (initget 1)
  12.   (setq co (getpoint "\nSelect a destination point : ")
  13.         co (nth (- (ascii ax) 88) co)
  14.   )
  15.   (if (setq ss (ssget '((0 . "INSERT,*TEXT"))))
  16.     (repeat (setq i (sslength ss))
  17.       (setq ed (entget (ssname ss (setq i (1- i))))
  18.             pt (assoc 10 ed)
  19.       )
  20.       (entmod
  21.         (subst
  22.           (cond
  23.             ( (= ax "X")
  24.               (list 10 co (caddr pt) (last pt))
  25.             )
  26.             ( (= ax "Y")
  27.               (list 10 (cadr pt) co (last pt))
  28.             )
  29.             ( (= ax "Z")
  30.               (list 10 (cadr pt) (caddr pt) co)
  31.             )
  32.           )
  33.           pt
  34.           ed
  35.         )
  36.       )
  37.       (if (and (= (cdr (assoc 0 ed)) "INSERT") (= (cdr (assoc 66 ed)) 1))
  38.         (progn
  39.           (setq e (cdr (assoc -1 ed)))
  40.           (while (= (cdr (assoc 0 (entget (setq e (entnext e))))) "ATTRIB")
  41.             (setq ed (entget e)
  42.                   ptt (assoc 10 ed)
  43.             )
  44.             (setq ed (entmod (subst (cons 72 0) (assoc 72 ed) ed)))
  45.             (setq ed (entmod (subst (list 11 0.0 0.0 0.0) (assoc 11 ed) ed)))
  46.             (entmod
  47.               (subst
  48.                 (cond
  49.                   ( (= ax "X")
  50.                     (list 10 (+ co (- (cadr ptt) (cadr pt))) (caddr ptt) (last ptt))
  51.                   )
  52.                   ( (= ax "Y")
  53.                     (list 10 (cadr ptt) (+ co (- (caddr ptt) (caddr pt))) (last ptt))
  54.                   )
  55.                   ( (= ax "Z")
  56.                     (list 10 (cadr ptt) (caddr ptt) (+ co (- (last ptt) (last pt))))
  57.                   )
  58.                 )
  59.                 ptt
  60.                 ed
  61.               )
  62.             )
  63.           )
  64.         )
  65.       )
  66.     )
  67.   )
  68.   (princ)
  69. )
  70.  
« Last Edit: August 15, 2016, 08:39:59 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with attributed blocks...
« Reply #4 on: August 15, 2016, 06:29:41 AM »
Thank you for your quick replay Marko, but we still have a problem..
I send you 2 pictures "before" and "after" invoking this function and of couse dwg file with attributed blocks.
I supose it's can help you to descript the code



ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Problem with attributed blocks...
« Reply #5 on: August 15, 2016, 06:48:34 AM »
danglar, you need to rotate those blocks along with their attributes... Just use rotate command with "reference" option and for first reference choose angled vector and for destination use your Xaxis aligned line - or turn ortho F8 and pick destination point somewhere on positive Xaxis value (for start point of rotation use OSNAP "end", and for picking vector use OSNAP "nea" and for destination vector turn OSNAP off F3 and pick point on Xaxis positive value)...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with attributed blocks...
« Reply #6 on: August 15, 2016, 06:56:07 AM »
Marko.  In a first step I need to move those blocks without any rotation. Those blocks must have same Y coodinate..
Rotation  - it's the second step. As you see from the pictures non attributed blocks receve same Y coordinate along horizontal line and I need the same thing for attributed blocks even they have initial rotation angle

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Problem with attributed blocks...
« Reply #7 on: August 15, 2016, 08:40:39 AM »
Ok, Igal, I've updated posted code... Test it now...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: Problem with attributed blocks...
« Reply #8 on: August 15, 2016, 08:56:05 AM »
Now it's work like a charm!
Thank you Marko. Today you save me a lot of time for preparing lighting supply flowcharts.
I jast combined your modification with Henrique subroutine in order to make a needful rotation in a same time (see attached lisp)