Block

Hello,Using AutoLISP on IntelliCAD 2000, how to insert a Block (from file) avoiding the "Block already exists..." message box?Is there a way to check if the block is already inserted on current drawing before try to insert it from file?Is there a way to automatically ignore the block redefinition and get the inserted one?Any tip?Regards,Fernando.

Comments

  • If I understand your problem correctly, the code below should solve it. You will lose the preview pane of the ddinsert command, since the getfiled command doesn't support it. Note that some of the earlier Bricsnet Intellicad versions require the Z scale prompt, add an extra pause to the insert command function if you are still using 2.2.0025 or 2.2.0016.Hope this helps.(defun c:test ( / char cnt fpath bn)(setq cnt (1- (strlen (setq fpath (getfiled "Insert block" "" "DWG" 4)))))(setq fpath2 (eval (substr fpath 1 (- (strlen fpath) 4))))(while (/= "\" char)(setq char (substr fpath2 (1- cnt) 1))(setq cnt (1- cnt)))(setq bn (substr fpath2 (1+ cnt)))(if (tblsearch "BLOCK" bn)(command ".insert" bn pause pause pause pause)(command ".insert" fpath pause pause pause pause)))

  • Vaernes this is great!As Im totally useless at LISP maybe you can help me editing this.What I would like to do is to put ^C^C^C_TEST;blockname in a menu.1.Where and how do I make it read my argument? (blockname)2.How do I put in a path?Thanks in advance.Patrik

  • It is best to change it to a lisp function with an argument (the block filename). The argument must contain the whole path to the block for there to be any point in doing this (i think). The function should look like this:(defun test ( fpath / char cnt bn)(setq cnt (1- (strlen fpath )))(setq fpath2 (substr fpath 1 (- (strlen fpath) 4)))(while (/= "\" char)(setq char (substr fpath2 (1- cnt) 1))(setq cnt (1- cnt)))(setq bn (substr fpath2 (1+ cnt)))(if (tblsearch "BLOCK" bn)(command ".insert" bn pause pause pause pause)(command ".insert" fpath pause pause pause pause)));eofNote that the fpath variable has been moved to the left of the slash character in the function definition. That means it is accepted as an argument to the function.The command line of the menu/toolbar item should look like this:(test "C:\blockfolder\anyfile.dwg")There must be no ^C^C^C_ before the expression.Hope this helps..

  • ThanksWorks great.

  • Hello,Thank you all but unfortunately I have found 2 bugs on INSERT command.Both are easy to reproduce:- Change UCS to any position different from WCS;- INSERT a block;- Note that the block are placed wrong.Also, if you insert a block with attributes the attributes are placed far away from block and both are placed wrong when the UCS are different from WCS.I have traced the first on IntelliCAD source code and think I have solved it but the second I did not get yet.If you are interested both bugs are on INSERT.CPP file on IntelliCAD source code.Regards,Fernando.

This discussion has been closed.