Author Topic: Request - align object.lsp  (Read 7025 times)

0 Members and 1 Guest are viewing this topic.

Fabricio28

  • Swamp Rat
  • Posts: 670
Request - align object.lsp
« on: January 17, 2013, 01:53:26 PM »
Hi guys,
I'm trying  to find out a lisp that align object to a polyline.

Can anybody help me out, please?

My file attached can explain better my task.

Thank in advance
« Last Edit: January 17, 2013, 02:50:21 PM by FABRICIO28 »

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Request - align object.lsp
« Reply #1 on: January 17, 2013, 04:01:33 PM »
No need for a custom program, just use the in-built ALIGN command:


Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Request - align object.lsp
« Reply #2 on: January 18, 2013, 05:39:00 AM »
Thanks for replay Lee,
I was using rotate reference command to align objects, I didn't know align command.
I was wondering if you had some command faster than align, because I have thousand of objects to align in my drawing.

I've tried to create a dinamic block with align parameter, but no success.

Thanks anyway.
Regards


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Request - align object.lsp
« Reply #3 on: January 18, 2013, 06:49:38 AM »
Thanks for replay Lee,
I was using rotate reference command to align objects, I didn't know align command.
I was wondering if you had some command faster than align, because I have thousand of objects to align in my drawing.

I've tried to create a dinamic block with align parameter, but no success.

Thanks anyway.
Regards


Are these objects blocks? Is it extremely important that they're placed on the exact endpoint?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Request - align object.lsp
« Reply #4 on: January 18, 2013, 07:34:00 AM »

Are these objects blocks? Is it extremely important that they're placed on the exact endpoint?

Yes, they are blocks. These blocks are placed in each endpoints of the polyline and aligned.

Regards.
 :-D

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Request - align object.lsp
« Reply #5 on: January 18, 2013, 07:39:10 AM »
Are they already placed there or would you like the lisp to place them on those points? I.e. are they on each and every endpoint, or only those where the user physically inserts them?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Request - align object.lsp
« Reply #6 on: January 18, 2013, 07:45:48 AM »
Hi, irneb
I'd like the lisp place the block in each endpoints.

thank you

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Request - align object.lsp
« Reply #7 on: January 18, 2013, 07:58:31 AM »
Very quickly written code:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:alignblocks ( / _block _ang b e i j p s )    
  2.     (if
  3.         (and
  4.             (setq b (LM:ssget "\nSelect Block to Align: " '("_+.:E:S" ((0 . "INSERT")))))
  5.             (setq s (LM:ssget "\nSelect LWPolylines: "    '(((0 . "LWPOLYLINE")))))
  6.         )
  7.         (progn
  8.             (eval
  9.                 (list 'defun '_block '( p r )
  10.                     (list 'entmake
  11.                         (list 'list
  12.                           ''(0 . "INSERT")
  13.                            '(cons 10 p)
  14.                            '(cons 50 r)
  15.                             (list 'quote (assoc 2 (entget (ssname b 0))))
  16.                         )
  17.                     )
  18.                 )
  19.             )
  20.             (defun _ang ( e p )
  21.                 (apply 'atan (cdr (reverse (vlax-curve-getfirstderiv e p))))
  22.             )
  23.             (repeat (setq i (sslength s))
  24.                 (setq e (ssname s (setq i (1- i))))
  25.                 (_block (vlax-curve-getstartpoint e) (_ang e 0))
  26.                 (_block (vlax-curve-getendpoint   e) (+ pi (_ang e (vlax-curve-getendparam e))))
  27.                 (repeat (fix (setq j (1- (vlax-curve-getendparam e))))
  28.                     (_block (setq p (vlax-curve-getpointatparam e j)) (_ang e j))
  29.                     (_block p (+ pi (_ang e (setq j (1- j)))))
  30.                 )
  31.             )
  32.         )
  33.     )
  34.     (princ)
  35. )
  36.  
  37. ;; ssget  -  Lee Mac
  38. ;; A wrapper for the ssget function to permit the use of a custom selection prompt
  39. ;;
  40. ;; Arguments:
  41. ;; msg    - selection prompt
  42. ;; params - list of ssget arguments
  43.  
  44. (defun LM:ssget ( msg params / sel )
  45.     (princ msg)
  46.     (setvar 'nomutt 1)
  47.     (setq sel (vl-catch-all-apply 'ssget params))
  48.     (setvar 'nomutt 0)
  49.     (if (not (vl-catch-all-error-p sel)) sel)
  50. )
  51.  

Example:





Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Request - align object.lsp
« Reply #8 on: January 18, 2013, 08:13:41 AM »
Hi Lee,
I'm really impressed with your code. It's just amazing!
Worked like a charm, I'll save a lot of time.

Many Thanks

May I ask you just one more thing.
Is there any way to remove the line bellow the blocks?

I really appreciate your help.

Kind Regards
 :-D

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Request - align object.lsp
« Reply #9 on: January 18, 2013, 08:19:33 AM »
Hi Lee,
I'm really impressed with your code. It's just amazing!
Worked like a charm, I'll save a lot of time.

Many Thanks

You're welcome, it was only a quick draft  :-)

May I ask you just one more thing.
Is there any way to remove the line bellow the blocks?

Add (entdel e) on a new line between line 30 & 31.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Request - align object.lsp
« Reply #10 on: January 18, 2013, 08:30:50 AM »
Sorry Lee,
My english is terrible. :ugly:
I mean, I'd like to trim the line on the blocks.

Regards


Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Request - align object.lsp
« Reply #11 on: January 18, 2013, 08:39:08 AM »
I mean, I'd like to trim the line on the blocks.

Ah, this is a little more difficult and would depend on the block dimensions & geometry.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Request - align object.lsp
« Reply #12 on: January 18, 2013, 08:43:28 AM »

Ah, this is a little more difficult and would depend on the block dimensions & geometry.

I see, Lee
But thanks for your wonderful job!

You helped me a lot.

Kind Regards

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Request - align object.lsp
« Reply #13 on: February 15, 2013, 03:04:06 PM »

Ah, this is a little more difficult and would depend on the block dimensions & geometry.

Hi Lee
I want to clean my drawings to remove excess overlapping of lines, etc but it takes time to delete 1 by 1.
I tried overkill command but it doesnt work the way I wanted it. Please help...

My block dimensions & geometry is default.

Kind Regards