为了进一步演示,下面是一个向ACAD\U LAYERFILTERS字典添加新图层特性过滤器(XRecord)的示例。如果ACAD\U LAYERFILTERS字典不存在(即,如果尚未将图层特性过滤器添加到图形中),则代码还将构建该字典。
- (defun test ( filter / dict xdict )
- (if
- (and
- (setq xdict
- (cdr
- (assoc 360
- (entget
- (cdr
- (assoc 330
- (entget (tblobjname "LAYER" "0"))
- )
- )
- )
- )
- )
- )
- (or
- (setq dict
- (cdr
- (assoc -1
- (dictsearch xdict "ACAD_LAYERFILTERS")
- )
- )
- )
- (setq dict
- (dictadd xdict "ACAD_LAYERFILTERS"
- (entmakex
- '(
- (0 . "DICTIONARY")
- (100 . "AcDbDictionary")
- (280 . 0)
- (281 . 1)
- )
- )
- )
- )
- )
- (not (dictsearch dict filter))
- )
- (dictadd dict filter
- (entmakex
- (list
- (cons 0 "XRECORD")
- (cons 100 "AcDbXrecord")
- (cons 280 1)
- (cons 1 filter)
- (cons 1 "#*")
- (cons 1 "3")
- (cons 1 "*")
- (cons 70 768)
- (cons 1 "*")
- (cons 1 "*")
- (list -3
- (list "ACAD"
- (cons 1000 "( NAME== "#*" ) and ( COLOR== "3" ) and LOCKED == "FALSE"")
- )
- )
- )
- )
- )
- )
- )
为清楚起见,我已将层过滤器属性硬编码到代码中,以便仅使用层过滤器名称调用该函数,即:
如果提供的名称(上面的“MyFilter”)在图形中尚未作为图层过滤器出现,则将向字典中添加一个新的图层过滤器。添加的图层过滤器将允许名称匹配“#*”、图层颜色为“3”且图层被解锁的图层(三个任意选择的属性用于演示)。
请注意,除了存储名称、颜色、线型等属性的多个DXF group 1代码外,xRecord还需要存储描述属性值的字符串的扩展数据。
图层过滤器的DXF代码没有文档记录,但我一路上收集了一些信息:
-
- ;; Layer Filter XRecord Data
- The following list details the various DXF codes and values contained in the Xrecord:
- 1 Name of Filter
- 1 Layer Name
- 1 Color
- 1 Linetype
- 70 (Please refer further below)
- 1 Lineweight
- 1 PlotStyle
- The 70 DXF code can contain one of the following numbers or an addition of them:
- ON/OFF
- On 1
- Off 3
- FREEZE/THAW
- Freeze 4
- Thaw 12
- CURRENT VPORT
- Freeze 16
- Thaw 48
- NEW VPORT
- Freeze 64
- Thaw 192
- LOCK/UNLOCK
- Lock 256
- UnLock 768
- PLOT
- Plot 1024
- Don't Plot 3072
我希望这有帮助。 |