Jump to content

Recommended Posts

Posted (edited)

So I have a library full of exported blocks (wblock)

Now I wanted to add an attribute to those blocks with the part name so I can use eattext. (since we use 2d blocks and they have multiple views I couldn't use the block names)

And since I am not working in a block but a dwg file of and exported block. I couldn't use any standard attribute lisps. I can't even use attedit since that asks for a block too.

So while I was making this post I figured it out by myself 8) so here is the code:

To add an attribute to the center of a drawing or a block if your in the block editor:

(command "-Attdef" "I" "P" "L" "" "partnr" "enter part number" "partnr" "style" "style1" (getvar "viewctr") "0")

to delete the old attribute ( I modified a block delete routine:

(defun C:delblk3 (blk / SS FILTER SSLEN ENT)
  (progn
  (setq	FILTER (list (cons 0 "ATTDEF")
	     (cons 2 blk)
       )
SS     (ssget "_X" FILTER)
 )
 (if SS
   (progn
     (vl-load-com)
     (repeat (setq SSLEN (sslength SS))
(vlax-invoke-method (vlax-ename->vla-object (ssname ss (setq SSLEN (1- SSLEN)))) 'Delete)
     )
   )
 )
  )
)
(c:delblk3 "partnr") ;; call it with this line.

Sharing it because 90% is from here anyway, I hope someone finds it helpfull :)

Edited by CADkitt

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...