ASMI,
This reactor works great if you type in the insert command.
However - this is how I insert blocks:
I define trigger commands in one long lisp:
Example:
Code:
(DEFUN c:2x4 () (load "2x4") (c:2x4) (princ))
Hundreds of these are defined at startup - I call them "triggers".
Then I have an icon menu that invokes the command.
Click the button and insert the block...
using a command similar to this:
Code:
(defun C:2x4 ( )
(setvar "cmdecho" 0)
(setvar "orthomode" 1)
(SETVAR "attreq" 0)
(setq ds (getvar "dimscale"))
(setq ip (getpoint "Insertion Point:"))
(setq clay (getvar "clayer"))
(command "-layer" "s" "E-LITE-CLNG-NEW" "")
(command "insert" "2x4" ip "" "" pause)
(SETVAR "attreq" 1)
;----------------------------------------------------------
(SETQ ENT (entlast))
(SETQ NXT (ENTNEXT ENT))
(IF (/= NXT nil)
(progn
(SETQ VAR (ENTGET NXT))
(WHILE (= (CDR (ASSOC 0 VAR)) "ATTRIB")
(SETQ VAR (SUBST '(50 . 0.0) (ASSOC 50 VAR) VAR))
(ENTMOD VAR)
(ENTUPD ENT)
(SETQ NXT (ENTNEXT NXT))
(SETQ VAR (ENTGET NXT))
)
)
)
;----------------------------------------------------------
(SETVAR "attreq" 1)
(setvar "clayer" clay)
(princ)
)
Everything between the ;---------------------------------------------------------- is the attribute rotate command that rotates the attribute to 0 degrees (horizontal).
when I load and turn on ATRON then run my command to insert the 2x4 block I get an error "Automation Error. Null extents".
I need to find a nice way of inserting your code into mine so that this command happens automatically.
Can you make the green box show up if Attreq = 0?
That would be ideal.... insert the block, green box comes up, pick new location - add attributes later.
Then I need to make a block editor that changes all the attributes in a selection set at once...
1. select set.
2. change all 1's attributes to user input.
then make one of these commands for all the second attributes.
then make one of these commands for all the third attributes.
This is what I have so far...
Code:
(DEFUN C:MAC (/ ENT NXT VAR)
(setq ss1 (ssadd)) ;Creates Blank Selection Set SS1
(setq ss2 (ssadd)) ;Creates Blank Selection Set SS2
(SETQ SS2 (SSGET '((0 . "INSERT")))) ;Prompts user for items to be rotated filtering for blocks only
(setq x (getstring "What Letter? "))
(SETQ OL (SSLENGTH SS2)) ;Determined length of SS2
(SETQ IOL 0) ;Sets initial counter to 0
(SETQ ENT (SSNAME SS2 0)) ;Selects first entity in SS2
(SETQ NXT (ENTNEXT ENT)) ;Gets the extended entity data for ENT if it exists
(WHILE (< IOL OL)
(IF (/= NXT nil) (SSADD ENT SS1)) ;Adds ENT to set SS1 only if it had extended entity data AKA attributes
(SETQ IOL (+ IOL 1))
(SETQ ENT (SSNAME SS2 IOL)) ;Gets next entity in SS2
(IF (= ENT nil) (SETQ NXT nil) (SETQ NXT (ENTNEXT ENT))) ;Sets NXT to nil if there are no more entities
)
(SETQ ENT (SSNAME SS1 0)) ;Gets first entity in SS1
(SETQ I 0) ;Sets counter to 0
(SETQ SL (SSLENGTH SS1)) ;Gets length of SS1
(WHILE (< I SL)
(SETQ NXT (ENTNEXT ENT)) ;Gets the extended entity data for ENT if it exists
(SETQ VAR (ENTGET NXT))
(WHILE (= (CDR (ASSOC 0 VAR))
"ATTRIB")
(setq stuff '((1 . x)))
(SETQ VAR (SUBST (cons 1 x) (ASSOC 1 VAR) VAR))
(ENTMOD VAR)
(ENTUPD ENT)
(SETQ NXT (ENTNEXT NXT))
(SETQ VAR (ENTGET NXT))
)
(SETQ I (+ I 1)) ;Incriments rotation While loop
(SETQ ENT (SSNAME SS1 I)) ;Gets next entity in SS1
)
)
then I have multiple attribute rotate (MAR)
Code:
(DEFUN C:MAR (/ ENT NXT VAR)
(setq ss1 (ssadd)) ;Creates Blank Selection Set SS1
(setq ss2 (ssadd)) ;Creates Blank Selection Set SS2
(SETQ SS2 (SSGET '((0 . "INSERT")))) ;Prompts user for items to be rotated filtering for blocks only
(SETQ OL (SSLENGTH SS2)) ;Determined length of SS2
(SETQ IOL 0) ;Sets initial counter to 0
(SETQ ENT (SSNAME SS2 0)) ;Selects first entity in SS2
(SETQ NXT (ENTNEXT ENT)) ;Gets the extended entity data for ENT if it exists
(WHILE (< IOL OL)
(IF (/= NXT nil) (SSADD ENT SS1)) ;Adds ENT to set SS1 only if it had extended entity data AKA attributes
(SETQ IOL (+ IOL 1))
(SETQ ENT (SSNAME SS2 IOL)) ;Gets next entity in SS2
(IF (= ENT nil) (SETQ NXT nil) (SETQ NXT (ENTNEXT ENT))) ;Sets NXT to nil if there are no more entities
)
(SETQ ENT (SSNAME SS1 0)) ;Gets first entity in SS1
(SETQ I 0) ;Sets counter to 0
(SETQ SL (SSLENGTH SS1)) ;Gets length of SS1
(WHILE (< I SL)
(SETQ NXT (ENTNEXT ENT)) ;Gets the extended entity data for ENT if it exists
(SETQ VAR (ENTGET NXT))
(WHILE (= (CDR (ASSOC 0 VAR)) ;Actual rotation loop
"ATTRIB")
(SETQ VAR
(SUBST '(50 . 0.0)
(ASSOC 50 VAR)
VAR
)
)
(ENTMOD VAR)
(ENTUPD ENT)
(SETQ NXT (ENTNEXT NXT))
(SETQ VAR (ENTGET NXT))
)
(SETQ I (+ I 1)) ;Incriments rotation While loop
(SETQ ENT (SSNAME SS1 I)) ;Gets next entity in SS1
)
)
Bookmarks