Author Topic: How to insert block over another?  (Read 2101 times)

0 Members and 1 Guest are viewing this topic.

Zykl0

  • Guest
How to insert block over another?
« on: November 23, 2008, 01:35:43 AM »
Hi!

I am trying to get a piece of code on this forum but i cant find something similar that i need.

I would like a routine that insert a block let's name it "takeout.dwg" on the insertion point of every block in my model that start with the layer "M-N-INC-GIC*" but the block "takeout.dwg" need to be exploded once inserted.

these block are on top of a line, once the takeout inserted i will be able to easily break the line and dimension the "real" pipe length but... one small thing.. once the pipe broke i will get stuck with a useless piece of pipe i don't know the exact measurement at the moment because i am not at job but i will trick my takeout.dwg to leave the pipe with an uncommon length, so its going to be easy to filter these line left alone in the drawing to delete them.

Here i need another small code snippet. something that do..

ssget LINE on LAYER M-N-INC* with an exact length of 24.77mm then delete them IF MEASUREMENT = 1
else
ssget LINE on LAYER M-N-INC* with an exact length of 0.9751 inch then delete them IF MEASUREMENT = 0

Thank you!  :-D

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to insert block over another?
« Reply #1 on: November 23, 2008, 08:57:01 AM »
You can start with this.
Code: [Select]
(defun c:test (/ ss len fuzz ename elst)
  (if (setq ss (ssget "_X" (list (cons 0 "LINE") (cons 8 "M-N-INC*") (cons 410 (getvar "ctab")))))
    (progn
      (if (zerop (getvar "MEASUREMENT"))
        (setq len 0.9751)
        (setq len 24.77)
      )
      (setq fuzz 0.0001)
      (setq i -1)
      (while (setq ename (ssname ss (setq i (1+ i))))
        (if (equal (distance (cdr (assoc 10 (setq elst (entget ename))))
                             (cdr (assoc 11 elst))
                   )
               len
               fuzz
            )
          (vla-delete (vlax-ename->vla-object ename))
        )
      )
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Zykl0

  • Guest
Re: How to insert block over another?
« Reply #2 on: November 26, 2008, 03:58:13 PM »
Cool Cab ill try that, but what about the main routine

I would like a routine that insert a block let's name it "takeout.dwg" on the insertion point of every block in my model that start with the layer "M-N-INC-GIC*" but the block "takeout.dwg" need to be exploded once inserted.

everything i see is a block to swap another :(