Jump to content

Inserting a point for a block


ramis

Recommended Posts

Good morning,

 

I have checked on the forum if there's an existing thread for this but i haven't find one.:oops:

 

I have a little question concerning AutoCAD. Is it possible to easily put a point for each block of a type. for example, I have some blocks with name 'WPI2 601' on a layer 'WPI 26'. Is there a way to select all theses type of blocks and for each blocks to put a point at the coordinates of the blocks...

 

I have many different blocks and many blocks (and also many files) so i can't do it manually. It will take too much time... and i can forget some of them.

 

Thanks for your help,

Ramis

Link to comment
Share on other sites

To put a point? How would you use this information? How about a text file containing a list with name, ins point and layer for each block in the drawing? It can be done with Lisp. Also it can be set to batch process all the drawing in a directory. You could open that file in Excel and reorder it as you wish. Would that help you?

Link to comment
Share on other sites

The AutoCAD will be put in a software to convert the information in an other format. But for the convertion to be good, the point object has to be set as point on the dxf file. The block are not conveted. But on my file, these objects are drawing with a block to have a more understandable chart. That's why I want to select each types of block to put a point for them to be converted. I maybe try to do this with a lisp but i am not very familiar with that language... I only use AutoCAD to prepare and reorganise the dxf files to have the best convertion possible with the maximum object converted to minimise the work then...

I don't know if my explanations and my English are clear...

Link to comment
Share on other sites

Thank you for your lisp function. But this function seems made the points manually. I am searching a way to do this automatically... I think that I have to filter all the block of the same type to select them and then, draw a point at their coordinates.

 

I have here a lisp function that should work but I don't know how to select the block correctly.

The problem comes from this line (setq ss (ssget '((0 . "BLOCK")(8 . "WPI26")))) where the selection is said to be nil. But when i am clicking on a block, it's this layer WPI26 that appears and the name of the block is WPI2 601...

 

(defun c:bck2pt ()

(princ "\nSelect blocks: ")

(setq ss (ssget '((0 . "BLOCK")(8 . "WPI26"))))

(setq Item 0)

(repeat (sslength ss)

(setq Ename (ssname ss Item))

(setq CtrPt (cdr (assoc 10 (entget Ename))))

(command "._point" CtrPt)

(setq Item (+ 1 Item))

)

(princ)

)

Link to comment
Share on other sites

Here's a way to do it without lisp.

 

Create a block out of a point. Then use "blockreplace". You can then "convert" those blocks to points by exploding them.

Link to comment
Share on other sites

I think that it will be easier for me to use a lisp because i have other things to do on the files so i will include this into a script...

I can select the block of the type that i want using

(setq ss (ssget "_x" '((0 . "INSERT")(8 . "WPI26"))))

here, the selection is not empty...

but when i run the lisp function with

(setq ss (ssget '((0 . "INSERT")(8 . "WPI26"))))

it is said " ; error: bad argument type: lselsetp nil "

 

this lisp function was originally to draw a point at the center of a circle, selecting the circle with the command

(setq ss (ssget '((0 . "CIRCLE")(40 . 7.5))))

 

maybe there is something to change in the rest of the lisp function to get the coordinates of the block...

Link to comment
Share on other sites

Try this:

 

(defun c:b2p(/ sBl cLay bSet)
 (if(and
   (setq sBl(entsel "\nPick sample block > "))
   (setq cLay(cdr(assoc 8(entget(car sBl)))))
   (setq bSet(ssget "_X" (list '(0 . "INSERT")(cons 8 cLay))))
   ); end and
  (progn
    (princ(strcat "\n"(itoa(sslength bSet)) " blocks found. "))
    (sssetfirst nil bSet)
    (initget 1 "Yes No")
    (setq cAns(getkword "\nAdd points? [Yes/No]: "))
    (if(= "Yes" cAns)
      (mapcar '(lambda(x)(command "_.point"
			   (cdr(assoc 10(entget x)))))
       (vl-remove-if 'listp
	 (mapcar 'cadr(ssnamex bSet))))
      ); end if
    ); end progn
  ); end if
 (princ)
 ); end of c:b2p

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...