你好
我有一个lisp,可以分解一个块,然后我可以编辑它。
我会把它扔到一个街区。
通过向下滑动block lisp制动器。
- (defun c:eb ( / wucs)
-
- (setq wucs (getvar "WORLDUCS")) ; if it is not at WORLD UCS
- (if (= wucs 0)
- (command "_UCS" "W") ; set it to WORLD
- ); end if
- (if G_blname ; if this variable exists
- (redefinebl) ; redfine the previously edited block
- (editbl) ; otherwise edit a block
- ); end if
- (if (= wucs 0) ; if it was not at WORLD UCS
- (command "_UCS" "v") ; set it to the previous UCS
- ); end if
- (princ)
- )
- ; error trapping - clears toggle variable on error or cancel
- ; the only trouble is that the "undo" command does not clear the toggle as well!
- (defun traperr (s)
- (if (or (/= s "Function cancelled")(= s "quit / exit abort") )
- (progn
- (if G_blname
- (progn
- (setq G_blname nil)
- ); end progn
- ); end if
- (setq G_pt nil)
- (princ)
- ); end progn
- (princ (strcat "\nError: " s))
- )
- ) ;end traperr
- (defun editbl (/ ent entl pt pt1 b)
- (setq temperr *error*)
- (setq *error* traperr)
- (setq ent nil) ; initialise
- (while (= ent nil) ; loop till a block is chosen
- (while (= ent nil) ; loop to stop user clicking off the target entity and causing an error
- (setq ent (entsel "\nWählen Sie einen Block zum Bearbeiten")) ; Sets ent to the selected entity
- (if (= ent nil) (prompt "\nKein Objekt gewählt, versuchen Sie es nochmals."))
- ); end while
- (setq entl (entget (car ent))) ; Sets entl to the selected entity's association list of the chosen
- entity
- (setq b (cdr (assoc 0 entl))) ; finds the entity type
- (setq pt1 (cdr (assoc 10 entl))) ; finds the insertion point
- (if (/= b "INSERT")
- (progn
- (setq ent nil) ; re-set if not a block to loop again
- (prompt "\nDas ist kein Block.")
- ); end progn
- )
- ); end while
- (setq G_blname (cdr (assoc 2 entl))) ; finds the block name & puts it in a global variable
- (setq pt (GETPOINT pt1 "\nCopy des Blocks für Bearbeitung: "))
- (command "_INSERT" G_blname pt 1.0 0.0 0.0) ; inserts the block again for redefining
- (setq ent (entlast)) ; Sets en to the name of the last entity in the drawing
- (setq entl (entget ent)) ; Sets ed to the entity data of entity ent
- (setq G_pt (cdr (assoc 10 entl))) ; finds the insertion point & puts it in a global variable
- (command "_EXPLODE" "_L" "") ; explodes this last entity
- (alert (strcat"\nDiese Copy vom "" G_blname "" würde Aufgelöst.\nRe-type: <EB> eingeben um den Block neu zu definieren nach Bearbeiten"))
- ;;(command "_scale")
- (setq *error* temperr)
- (princ)
- ); program ends
- (defun redefinebl ()
- (setq temperr *error*)
- (setq *error* traperr)
- (command "_-Block" G_blname "_y" G_pt) ; the "Y" is because the commands asks if you want to re-define the block
- (setq G_blname nil) ; set to nil as this is used as a redefine/edit toggle
- (setq G_pt nil) ; set to nil to free up memory
- (setq *error* temperr)
- )
你能帮助我吗? |