Place a marker in the insertion point of all blocks in a drawing

Place a marker in the insertion point of all blocks in a drawing

TaytaRuiz
Participant Participant
972 Views
9 Replies
Message 1 of 10

Place a marker in the insertion point of all blocks in a drawing

TaytaRuiz
Participant
Participant

Hello everyone,
I have the problem that on a big set of DWG files I need to place a marker point or a "X" made of two 3mm lines in the insertion point of all the available blocks.

 

The issue is that the insertion point isn't available in Revit for dimensioning and due to some bad workflows one symbol in the floor plan generates 2 or more block definitions.

My hope is that someone has encountered the problem and could give me something to readily use or point me in the right direction about what tool to use for this problem.

Cheers

0 Likes
Accepted solutions (1)
973 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

Is the idea that you have an INTersection you can Osnap to at all Block insertion points?  If so, can the Lines be made part of the Block definition, rather than be independent objects?  That would mean you don't need to find all Block references or insertions, but need only to get into each Block definition, once, and add the Lines.  That will also save memory, and the X's will go with the Blocks when you Move them, etc.  Since within the BEDIT command the insertion point is always 0,0, it's also quite easy to draw the Lines in the right place.  Try this:

 

(defun C:BXIP ; = Blocks: add X at all Insertion Points
  (/ blk)
  (while (setq blk (tblnext "block" (not blk)))
    (if (not (assoc 1 blk)); not an Xref [no file path]
      (command "_.bedit" (cdr (assoc 2 blk))
        "_.line" "_non" "-1.5,-1.5" "_non" "1.5,1.5" ""
        "_.line" "_non" "-1.5,1.5" "_non" "1.5,-1.5" ""
        "_.bclose" "_save"
      ); command
    ); if
  ); while
  (prin1)
)

 

It draws the Lines on the current Layer, and assumes your drawing unit is a millimeter and that your 3 mm is the total length of each Line [not from the X intersection to the ends], but all those things can be adjusted. 

 

You could also use Points, and NODe Osnap, which would simplify it a little, because it would mean drawing only one thing in each edited Block definition.  It would also mean [with appropriate PDMODE setting] the added things would not change the appearance of the Blocks.

Kent Cooper, AIA
Message 3 of 10

john.uhden
Mentor
Mentor

@Kent1Cooper ,

I would also suggest using AutoCAD Points, preferably on a NoPlot layer.  But don't use layer DEFPOINTS as you cannot change either the PDMODE or the PDSIZE of any Point on that layer.  But you could make the layer a gaudy color like 230.

Personally I like color 21 as it is coral, like the deck of my former Barnegat Bay Sneakbox.  I'd love to be able to buy a Melges E-Scow with a white hull and coral deck.  They are hugely popular with the best sailors here on Barnegat Bay.

John F. Uhden

0 Likes
Message 4 of 10

Sea-Haven
Mentor
Mentor

Just a simple answer, give it a try.

 

(defun c:wow ( / ss x ent pt)
(setq ss (ssget "X" '((0 . "INSERT"))))
(if (= ss nil)
(alert "No blocks found \nwill now exit ")
(progn
  (setvar 'pdmode 34)
  (repeat (setq x (sslength ss))
    (setq ent (entget (ssname ss (setq x (1- x)))))
    (setq pt (cdr (assoc 10 ent)))
    (command "point" pt)
  )
)
)
(princ)
)

(defun c:unwow ( / ss)
(setq ss (ssget "X" '((0 . "POINT"))))
(if (= ss nil)
(alert "No points found ")
(command "erase" ss "")
)
(princ)
)

 

Message 5 of 10

TaytaRuiz
Participant
Participant
Thank you, I will give a try during the day.
0 Likes
Message 6 of 10

john.uhden
Mentor
Mentor

@Sea-Haven ,

Unless I have gone daft (a possibility), it seems you are placing a Point at each insertion of a block reference.  In that case if one moves a reference without moving the "associated" Point, there is no longer a meaningful relationship between the Point and the insert.  @Kent1Cooper offered what I believe to be the correct solution.

If the OP doesn't accept it, then I will for him (can I really do that?).

John F. Uhden

Message 7 of 10

TaytaRuiz
Participant
Participant

After testing the solutions yesterday, I found that the AutoCAD Point objects aren't recognised in Revit.

So, the script from @Kent1Cooper did what I needed as a middle-man script between the DWGs from a third-party and my team's Revit Model.

0 Likes
Message 8 of 10

trmaEGMSS
Participant
Participant

Can you show me what this looks like if I want it to add points instead of lines, and my drawings are in meter, not mm?

 

Edit: Nevermind. I used the answer from @Sea-Haven in this post.

0 Likes
Message 9 of 10

trmaEGMSS
Participant
Participant

Can this lisp be changed so it inserts points on the same layer where each block is and with the same color as that layer?

0 Likes
Message 10 of 10

ec-cad
Collaborator
Collaborator

Here is new model. Try it out. You may want to adjust the PDSIZE for your

drawings.

 

ECCAD

;; Original by Sea Heaven 11-21-23
;(defun c:wow ( / ss x ent pt)
;(setq ss (ssget "X" '((0 . "INSERT"))))
;(if (= ss nil)
;(alert "No blocks found \nwill now exit ")
;(progn
;  (setvar 'pdmode 34)
;  (repeat (setq x (sslength ss))
;    (setq ent (entget (ssname ss (setq x (1- x)))))
;    (setq pt (cdr (assoc 10 ent)))
;    (command "point" pt)
;  )
;)
;)
;(princ)
;)

;(defun c:unwow ( / ss)
;(setq ss (ssget "X" '((0 . "POINT"))))
;(if (= ss nil)
;(alert "No points found ")
;(command "erase" ss "")
;)
;(princ)
;)

;; Your question "Can this lisp be changed so it inserts points on the same layer where each block is and with the same color as that layer?"
;; Here's the changed code.
;;

(defun c:wow ( / ss x ent pt)
 (setq osm (getvar "OSMODE"))
 (setq clay (getvar "clayer"))
 (command "_color" "ByLayer")
 (setvar "OSMODE" 0); turn off OSnap mode
 (setvar "pdmode" 34); make a X with a circle style
 (setvar "pdsize" 5.0); Adjust as needed, this is for Metric A2 paper size
;
  (setq ss (ssget "X" '((0 . "INSERT"))))
   (if (= ss nil)
    (alert "No blocks found \nwill now exit ")
     (progn
       (repeat (setq x (sslength ss))
        (setq ent (entget (ssname ss (setq x (1- x)))))
        (setq lay (cdr (assoc 8 ent))); block layer
        (setq pt (cdr (assoc 10 ent))); get insertion point
        (setvar "clayer" lay); set us on Block layer
        (command "_point" pt); insert the Point
       ); repeat
     ); progn
    ); if
 (setvar "OSMODE" osm); reset OSnap mode
 (setvar "clayer" clay); reset Layer
 (princ)
); function wow


(defun c:unwow ( / ss)
(setq ss (ssget "X" '((0 . "POINT"))))
(if (= ss nil)
(alert "No points found ")
(command "erase" ss "")
)
(princ)
)
0 Likes