Message 1 of 1
Batch inserting blocks via the Forge API

Not applicable
12-15-2016
01:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to use the Forge API to insert a collection of blocks into a border arranged into a grid.
In my research into this I discovered a script wrote by Kent1Cooper which appears to to what I'm looking for. I've copied and tested the script but I cannot get it to run on my local version of AutoCAD.
(defun C:BC (/ blkfolder space nextLL rowht rowL blkLL blkUR objwid objht) (vl-load-com) (setvar 'osmode 0) (setq blkfolder (getfiled "Find folder" "Double-click any file in desired folder: " "dwg" 0) blkfolder (substr blkfolder 1 (1+ (vl-string-position 92 blkfolder 1 T))); path without dwg name space 1 ; between blocks and min. from limits <------ set as desired nextLL (mapcar '+ (getvar 'limmin) (list space space 0)); lower left of next block rowht 0 ; height of tallest block in row rowL nextLL; left end of baseline of row ); end setq (foreach blk (vl-directory-files blkfolder "*.dwg" 1) (command "_.insert" (strcat blkfolder blk) (getvar 'viewctr) "" "" "") (vla-getboundingbox (vlax-ename->vla-object (entlast)) 'minpt 'maxpt) (setq blkLL (vlax-safearray->list minpt) blkUR (vlax-safearray->list maxpt) objwid (- (car blkUR) (car blkLL)) objht (- (cadr blkUR) (cadr blkLL)) ) (if (> (+ (car nextLL) objwid space) (car (getvar 'limmax))) (setq ; then - start new row above previous row nextLL (polar rowL (/ pi 2) (+ rowht space)) rowL nextLL rowht 0 ); end setq ); end if - no else [next in current row] (command "_.move" (entlast) "" blkLL nextLL) (setq nextLL (polar nextLL 0 (+ objwid space))) (if (> objht rowht) (setq rowht objht)) ); end foreach ); end defun
Could anybody help me understand why the script won't run or what I'd have to do to update it. I'm afraid it's a bit beyond my scripting skills.
Thanks