Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert point at every block

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
RocksterB
712 Views, 14 Replies

Insert point at every block

I need a routine that inserts a point at the insert point or block named "Insert_Point" at every block in the file. The routine could use the current layer, which would be set prior to starting the routine. If it could request the user for the PDMode value and PDSize that would be great too. This will assist me in creating block libraries. Thanks in advance.

14 REPLIES 14
Message 2 of 15
BlackBox_
in reply to: RocksterB

You should be able to pull what you need from this thread:

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/insert-point-at-list-block-and-dinami...



"How we think determines what we do, and what we do determines what we get."

Message 3 of 15
3wood
in reply to: RocksterB

Many years ago, before AutoDesk Design Center was born, I had been using a routine named BLOCKMAN. It creates image for blocks in a library and put a red cross at the insert point in the image.

Message 4 of 15
hmsilva
in reply to: RocksterB


@Anonymous wrote:

I need a routine that inserts a point at the insert point or block named "Insert_Point" at every block in the file. The routine could use the current layer, which would be set prior to starting the routine. If it could request the user for the PDMode value and PDSize that would be great too. This will assist me in creating block libraries. Thanks in advance.


randy,
to insert a point at the insertion point at every blocks in the file,
perhaps something like this

 

(defun c:test (/ ent itm num pdm pds ss)
  (if (setq ss (ssget "_X" '((0 . "INSERT"))))
    (progn
      (while (= (member pdm '(0 1 2 3 4 32 33 34 35 36 64 65 66 67 68 96 97 98 99 100)) nil)
	(setq pdm (getint
		    (strcat "\Enter new value for PDMODE <"(rtos (getvar "pdmode"))">: ")))
	(if (null pdm)
	  (setq pdm (getvar "pdmode"))
	);; if
	(if (= (member pdm '(0 1 2 3 4 32 33 34 35 36 64 65 66 67 68 96 97 98 99 100)) nil)
	  (progn
	    (prompt "\nRequires one of these values: 0,1,2,3,4,32,33,34,35,36,64,65,66,67,68,96,97,98,99 or 100.\n")
	    (setq pdm nil)
	  );; progn
	);; if
      );; while
      (setq pds	(getint
		  (strcat "\Enter new value for PDSIZE <"(rtos (getvar "pdsize"))">: ")))
      (if (null pds)
	(setq pds (getvar "pdsize"))
      )
      ;; if
      (setvar "pdmode" pdm)
      (setvar "pdsize" pds)
      (setq itm	0
	    num	(sslength ss)
      )
      (while (< itm num)
	(setq ent (entget (ssname ss itm)))
	(if
	  (/= (logand 4 (cdr (assoc 70 (tblsearch "block" (cdr (assoc 2 ent))))))4)
	   (progn
	     (entmakex (list (cons 0 "POINT")
			     (cons 10 (cdr (assoc 10 ent)))
			     (cons 410 (cdr (assoc 410 ent)))
		       )
	     )
	   );; progn
	);; if
	(setq itm (1+ itm))
      );; while
    );; progn
  );; if
);; test

 

 hope that helps
Henrique

 

EESignature

Message 5 of 15
RocksterB
in reply to: 3wood

I saw BlockMan going to $95 bucks. Is this the one you previously used?

 

Henrique, I'll give your routine a try on Monday.

Message 6 of 15
_Tharwat
in reply to: hmsilva

@ Henrique

 

There is no need to reconstruct the same dxf code two times .

 

This ...

 

(cons 410 (cdr (assoc 410 ent)))

 is enough with this .

 

(assoc 410 ent)

 

Message 7 of 15
hmsilva
in reply to: _Tharwat

Tharwat,
attentive, as always, and absolutely correct...

Cheers
Henrique

EESignature

Message 8 of 15
RocksterB
in reply to: hmsilva

That was just what I needed. Thanks again!

Message 9 of 15
hmsilva
in reply to: RocksterB

You're welcome, randy
glad i could help

Henrique

EESignature

Message 10 of 15
pbejse
in reply to: RocksterB


@Anonymous wrote:

I need a routine that inserts a point at the insert point or block named "Insert_Point" at every block in the file. The routine could use the current layer, which would be set prior to starting the routine. If it could request the user for the PDMode value and PDSize that would be great too. This will assist me in creating block libraries. Thanks in advance.


Not sure, but why not incorporate the "point" entitiy on the block

 

(defun C:adp (/ ss a)
    (command "_ddptype")
    (if (setq ss (ssget '((0 . "INSERT"))))
      (repeat (setq i (sslength ss))
       (if
          (not (member (setq
                         bn (Vla-get-effectivename
                              (vlax-ename->vla-object (ssname ss (setq i (1- i))))
                            )
                       )
                       data
               )
          )
           (vla-addpoint
             (vlax-ename->vla-object
               (cdr
                 (assoc 330 (entget (tblobjname "BLOCK" bn)))
               )
             )
             (vlax-3D-point 0 0)
           )
        )
      )
    )
    (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports
)

  )

 

Message 11 of 15
_Tharwat
in reply to: pbejse

   (if (not (member bn data))
        (progn
          (setq data (cons bn data))
           (vla-addpoint
           .......

Out of offense , The above part was missing  Smiley Wink

Message 12 of 15
pbejse
in reply to: _Tharwat

Indeed it is , Good catchTharwat

 

Thanks dude 

 

Message 13 of 15
RocksterB
in reply to: pbejse

Although applying the point to the block sounds good in theory, it problematic in practice. There are various design reasons why a user may have to display points by their style in their design file. I wouldn't want their design points to interfere with the point in a block. Good thinking out of the box though.Smiley Wink

 

Tharwat, exactly where do I put those additional code line?

Message 14 of 15
_Tharwat
in reply to: RocksterB


@Anonymous wrote:

Tharwat, exactly where do I put those additional code line?


All creadit goes to pbejse Smiley Happy

 

(defun c:test (/ ss i bn lst)
  (or doc
      (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (command "_ddptype")
  (if (setq ss (ssget '((0 . "INSERT"))))
    (repeat (setq i (sslength ss))
      (if
        (not (member (setq
                       bn
                        (Vla-get-effectivename
                          (vlax-ename->vla-object (ssname ss (setq i (1- i))))
                        )
                     )
                     lst
             )
        )
         (progn
           (setq lst (cons bn lst))
           (vla-addpoint
             (vla-item (vla-get-blocks doc) bn)
             (vlax-3D-point 0 0)
           )
         )
      )
    )
  )
  (vla-regen doc
             acAllViewports
  )
  (princ)
)
(vl-load-com)

 

Message 15 of 15
RocksterB
in reply to: pbejse

Thank you!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost