Message 1 of 4

Not applicable
07-15-2015
11:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I''m writing a script to export a grid layout (example shown in the image above) into a text file. Everything else is now working correctly, but somehow the script grabs a wrong block name (which seems like a temporary name) for one of my selection statement, screwing everything up (marked as red bold below).
;; For each grid, traverse through each cell to check if panel exists inside
;; Create an 2d array to mark the occupancy (of panels) for each grid
(setq n gridtot tmpset gridset) (while (> n 0) (setq n (1- n) row (caadar tmpset) y (- (cadaar tmpset) (/ *distver 2)) resultgrid nil ) (while (> row 0) (setq row (1- row) col (car (cdadar tmpset)) x (+ (caaar tmpset) (/ *disthor 2)) resultrow nil ) ;; For each cell in the row, grab all blocks inside the area to detect the ;; specified block (given as *blkname) ;; Insert 1 (true) for each occupied cell, and 0 (false) for unoccupied cell (while (> col 0) (setq col (1- col) fp (list (- x (/ *disthor 2.2)) (- y (/ *distver 2.2))) sp (list (+ x (/ *disthor 2.2)) (+ y (/ *distver 2.2))) ssp (ssget "_C" fp sp '((0 . "INSERT"))) ssl (cond (ssp (sslength ssp)) (0)) found nil ) (while (> ssl 0) (setq ssl (1- ssl) blkname (cdr (assoc 2 (entget (ssname ss ssl)))) ) (if (= blkname *blkname) (setq found T) ) ) (if found (setq resultrow (append '(1) resultrow)) (setq resultrow (append '(0) resultrow)) ) ) (setq resultgrid (cons resultrow resultgrid) y (- y *distver) ) ) )
The red block that I'm trying to detect is named as "SDA_PANEL". However, when I am debugging, the script picks it up as "*U8" (see images below).
How would I be able to resolve this?
P.S.
Is it a good practice to add a few lines at the top to save all system variables, then to load it back at the bottom?
Solved! Go to Solution.