Jump to content

Recommended Posts

Posted

Dear All,

 

 

I have a problem replacing blocks (titleblock) which is sometimes a dynamic block.

When replacing blocks with a new one i get a lselsetp nil error when there is a dynamic block involved.

 

 

What i try to do is the following:

 

 

- I try to replace the block by finding it by name (so no manual selection is needed because of a script)

- read the coordinates of the old block

- read the scale of the old block

- delete the block

- purge all unused blocks in the drawing

- insert the new one in the drawing at the right scale and coordinates

 

 

The A0KILL does work for static blocks but someone used dynamic ones in our drawings. Now i have to do these blocks by hand for 15000 drawings.

 

 

Can anyone help me with this issue?

 

 

(Old blockname is OHTITLE the new one OH-TITLE)

 

 

(DEFUN C:A0KILL()

(setq OHINS (cdr (assoc 10 (entget (ssname (ssget "X" '((2 . "OHTITLE"))) 0)))))

(setq OHX (cdr (assoc 41 (entget (ssname (ssget "X" '((2 . "OHTITLE"))) 0)))))

(setq ss (ssget "X" '((0 . "INSERT")(2 . "OHTITLE"))))

(command "_.erase" ss "")

(repeat 3

(command "_.purge" "_B" "*" "_N")

) ; end repeat

(command

"-insert";Command

"K:\\AutoCAD Standaard\\2014\\ALGEMEEN\\Kaders\\Titelh\\Nederlands\\A0\\OH-TITLE.DWG" ;Block Name

OHINS

OHX

""

)

(setq OHINS nil)

(setqoh OHX nil)

(setq ss nil)

)

Posted
Dear All,

 

 

I have a problem replacing blocks (titleblock) which is sometimes a dynamic block.

When replacing blocks with a new one i get a lselsetp nil error when there is a dynamic block involved.

 

 

What i try to do is the following:

 

 

Hi Marcel,

 

 

Dynamic block have a dynamic name (*U) so you would have to get its effective name. Maybe my RlxBlk would be up for the job but I would need a couple of example drawings and the titleblock(s) to test it on.

 

 

gr. Rlx

Posted

Hoi Marcel,

 

 

Think RlxBlk will do the job , maybe even on a folder but you would have to test that yourself (on a backup). Just make sure you clear all attribute properties in the main dialog except the value toggle. Just a few post below you can find this routine. You can link all attributes with the 1 : 1 button so you wont have to type over all the data. Just open a drawing , old block is OHTITLE (select with list button next to left image) , select new titleblock with file button next to the right image , link the attributes and that should do it...

 

 

If succeslfull , you can then try to do a complete folder with the folder button but again , test it on a backup first.

 

 

gr. Rlx

Marcel.jpg

Posted

I'll try it Rlx!

But can i do it without interaction in a script?

Posted
I'll try it Rlx!

But can i do it without interaction in a script?

 

 

Not in its current form , its just one of the things on my wishlist , although it wouldn't be a huge thing cause one would only have to bypass the dialog in the main subroutine. Since the program is relatively new it must first earn my confidence. But if the folder option works as intended it should be reasonably fast so you can do your script afterwards.

 

 

gr. Rlx

Posted
I'll try it Rlx!

But can i do it without interaction in a script?

 

 

You would add something like this to the program (untested) :

 

 

 (defun c:RlxBlk_Script ()(RlxBlk_Init)(RlxBlk_Doit)(command ".qsave")) 

 

 

Let the script load RlxBlk and call program with (c:RlxBlk_Script). If the script saves the drawing you can loose the command call in the code.

 

 

Gr. Rlx

Posted

That could help because i try to put it in one command. I also have drawings with A4 and A3 titleblocks. And they are working with my A0Kill command but not the Dynamic blocks.

That way i can select thousands of drawings in one time and open them, execute the block replacement command, synchronize the attributes to the new block from my edm system, qsave and close the drawing and go on to the next drawing.

Posted

If it works , fine , if not you can also update your own code because maybe my app is a little tiny bit over the top in your case

 

 

(quickly written and totally untested)

 

 

(defun c:A0Kill-2 ( / fn oatr ss i e blk n ohins ohx)
 (vl-load-com)
 (setq oatr (setvar "ATTREQ")) (setvar "ATTREQ" 0)
 (if (and (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 "`*U*,OHTITLE" ))))
   (setq fn
   (findfile
     "K:\\AutoCAD Standaard\\2014\\ALGEMEEN\\Kaders\\Titelh\\Nederlands\\A0\\OH-TITLE.DWG")))
   (progn
     (repeat (setq i (sslength ss))
(setq obj (vlax-ename->vla-object (setq blk (ssname ss (setq i (1- i))))))
(if (vlax-property-available-p obj 'effectivename)
  (setq n (vla-get-effectivename obj))(setq n (vla-get-name obj)))
(if (wcmatch (strcase n) "OHTITLE")
  (progn
    (setq ohins (cdr (assoc 10 (entget blk))) ohx (cdr (assoc 41 (entget blk))))
    (vla-delete obj)
    (command "-insert" fn ohins ohx "")
  )
)
     )
   )
 )
 (vla-purgeall (vla-get-activedocument (vlax-get-acad-object)))
 (setvar "ATTREQ" oatr)
 (princ)
)

 

 

succes!

 

 

gr. Rlx

Posted

Hoi rlx,

 

 

Everything works fine after a few ajustments like removing the attreq settings etc.

I also removed the last purge..

 

 

Thx!!

 

 

Solved!

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