以某种方式 你好
这是我到目前为止设法编写的代码,基于此代码有一些问题
1.当要求用户选择实体时,如何防止用户丢失实体?
2.如何用(and)而不是嵌套if来编写主函数(isotyp)
3?
4.为什么osnap没有启动
(setq TEMPTARGETLAYERNAME "SG_TEMP")
(setq TEMPTARGETLAYERCOLOR 5)
(setq ISOLATED T)
(setq ISOSET nil) ;_hold isolated layers data
(setq ISOVIS 0) ;_set isolated to frozen or locked
;;----------------=={ Isolate by type }==---------------------;;
;; ;;
;;Isolate all drawing's entityes by the choosen ;;
;;target type. ;;
;; ;;
;;------------------------------------------------------------;;
;;Author: Shay Gaghe, Copyright © 2014 ;;
;;------------------------------------------------------------;;
;;---Function Syntax : isotyp , unisotype(not active) ;;
;;-- Current Version : 0.1 ;;
;;-- Version History : 0.0 Date: 11.04.14 ;;
;;------------------------------------------------------------;;
;;----------------=={ SG:applyToSset }==----------------------;;
;; ;;
;;set all the givan selection set's members to a gien dxf ;;
;;entry and value. ;;
;;------------------------------------------------------------;;
;;Author: Shay Gaghe, Copyright © 2014 ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;sset - a selection set ;;
;;dxfe - dxf entry to substitue ;;
;;dxfv - the new dxf value ;;
;;------------------------------------------------------------;;
(defun SG:applyToSset(sset dxfe dxfv / e i n)
(setq i 0)
(while (< i (sslength sset))
(setq e (entget (ssname sset i)))
(setq n (entmod (subst (cons dxfe dxfv) (assoc dxfe e) e)))
(setq i (1+ i))
)
T
)
;;----------------=={ SG:createLayer }==----------------------;;
;; ;;
;;creates a new layer withe <name> name and <color> color.;;
;;------------------------------------------------------------;;
;;Author: Shay Gaghe, Copyright © 2014 ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;name - a string representing the layer name ;;
;;color- integer representing the layer color ;;
;;------------------------------------------------------------;;
;;Returned value: ;;
;;entity name of the name created entity ;;
;;------------------------------------------------------------;;
(defun SG:createLayer(name color)
(entmakex (list '(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
'(70 . 0)
(cons 2 name)
(cons 62 color)
)
)
)
;;----------------=={ SG:applyToAllLayers }==--------------------;;
;; ;;
;;apply a givan property and value to all drawing layers ;;
;;expet the current current one. ;;
;;------------------------------------------------------------;;
;;Author: Shay Gaghe, Copyright © 2014 ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;dxfe - dxf entry to substitue ;;
;;dxfv - the new dxf value to apply ;;
;;------------------------------------------------------------;;
(defun SG:applyToAllLayers(dxfe dxfv / la ob ladef)
(setq ISOLATED T)
(while (setq la (tblnext "LAYER" (null la))) ;_set all layers (except target) to froozen
(if (not (equal (cdr (assoc 2 la))
(getvar "CLAYER")
))
(progn
(setq ob (tblobjname "LAYER" (cdr (assoc 2 la))))
(setq ladef (entget ob))
(setq ISOSET (cons ladef ISOSET))
(if (assoc dxfe ladef)
(entmod
(subst
(cons dxfe dxfv)
(cons dxfe
(cdr (assoc dxfe (setq ladef (entget ob)))))
ladef
)
)
(entmod (append la '((dxfe . dxfv))))
)
)
)
)
)
(defun C:isotyp(/ ent sset i e cl f)
(setvar "CMDECHO" 0) ;_turn off native command text
(setvar "OSMODE" 0) ;_turn off osnap
(command "undo" "m") ;_set undo mark
(if (setq ent ;_ask user to select entity, if user miss it, program is terminated
(car (entsel
"\n Select the entity type you want to isolate \n")))
(if (setq sset (ssget "_X" (list (assoc 0 (entget ent))))) ;_get all entities of the selected type as a selection set
(if (< 1 (sslength sset))
(if (not (tblsearch "LAYER" TEMPTARGETLAYERNAME)) ;_make sure the temp layer is not in use
(if (SG:createLayer ;_create layer
TEMPTARGETLAYERNAME
TEMPTARGETLAYERCOLOR)
(if (SG:applyToSset sset 8 TEMPTARGETLAYERNAME) ;_move all members of sset to the temp layer
(progn
(setvar "clayer" TEMPTARGETLAYERNAME) ;_set temp layer as the current layer
(cond
((eq ISOVIS 0) (SG:applyToAllLayers 70 1)) ;_set all layers exept current to froozen
((eq ISOVIS 1) (SG:applyToAllLayers 70 4) ;_set all layers exept current to lock
))
(princ
(strcat
"\NAll entities of the type "
(cdr (assoc 0 (entget (ssname sset 1))))
" has been isolated"
)
)
) ;_progn
(princ "\Ncannot apply properties to selection set")
) ;_if
(princ "\NTemp layer could not e created")
) ;_if
(princ (strcat "\nLayer "
TEMPTARGETLAYERNAME
"is in use terminate function"
)
)
) ;_if
(princ "no entities of this type")
) ;_if
(princ "cant get entities from database")
) ;_if
(princ "\nUser didnt select en entity or exit prematurly")
)
(princ)
)
没有回复
有那么糟糕是什么意思?
我需要你们的支持!
很多用户在这里都有同样的话要告诉你
什么意思? 如果你不关注你的帖子,那意味着你对输入的内容不满意,一点也不感激,这将向用户发出信号,让他们不再愿意帮助同一个用户。 塔瓦是唯一一个有这种态度的人。所有用户都能理解,并非所有用户都有时间和地点关注帖子。我很感激,也很高兴成为这个社区的一员,没有你们,我什么都不知道。 samifox,
你真的需要开始做一些自己的研究这里有几个好地方开始,书签他们快速参考;
http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff18cb41610ec0a2e719-7a04.htm
http://www.lee-mac.com/index.html
http://www.afralisp.net/autolisp/
页:
1
[2]