马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- ; By Jeffery P Sanders Copyright 2002 by JefferyPSanders.com
- (defun C:CXF()
- ;turn the command echo off
- (setvar "cmdecho" 0)
- ;save some system variables
- (setq origCmddia(getvar "cmddia"))
- (setq origFiledia(getvar "filedia"))
- ;set some system variables
- (setvar "cmddia" 0)
- (setvar "filedia" 0)
- ;print a string to the command line to define what we are asking for (since entsel only asks for an object)
- (princ "\n Select XRef or Block: ")
- ;select entity
- (if (setq entselected(entsel))
- (progn
- ;save the entity name
- (setq en(car entselected))
- ;save the point selected
- (setq selectedPt(cadr entselected))
- ;get entity group codes
- (setq enlist(entget en))
- ; if it is a block
- (if(= "INSERT" (cdr(assoc 0 enlist)))
- (progn
- ;get the dxf group codes for the first sub-entity
- (setq enlist2(tblNext "block" en))
- ;save the file name of the block
- (setq shortFileName(cdr(assoc 2 enlist2)))
- ;set a mark for the undo command
- (command "undo" "mark")
- ;make the XREF part of the drawing temporarily
- (command "-xref" "bind" shortFileName)
- ;explode the block temporarily
- (command "explode" en)
- ;get the entity at the point selected originally if it exist
- (if (setq eset(ssget selectedPt))
- (progn
- ;get the name of the entity selected
- (setq en(ssname eset 0))
- ;get the DXF group codes of the entity
- (setq enlist(entget en))
- ;make a wblock named "X2"
- (if(findfile "x2.dwg")
- (command "_wblock" "x2" "y" "" selectedPt en "")
- (command "_wblock" "x2" "" selectedPt en "")
- )
- ;undo everything back to the marked position
- (command "undo" "Back")
- ;insert the X2 block
- (setq pt1(getpoint selectedPt "\n Insertion Point: "))
- (command "insert" "*x2" pt1 "" "")
- )
- (alert "*Error* - Select a sub-entity.")
- )
- )
- (alert "*Error* - Select a block or an XREF.")
- )
- )
- (alert "*Error* - Select a block or an XREF please.")
- )
- ;reset system variables
- (setvar "cmddia" origCmddia)
- (setvar "filedia" origFiledia)
- (setvar "cmdecho" 1)
- ;make a clean exit
- (princ "\n ...CPYXREF.lsp Complete. ")
- (princ "\n By: Jeffery P. Sanders 7/19/02 Copyright 2002 by jefferypsanders.com")
- (princ)
- )
|