
- ;==================================================================================================
- ;函 数: C:OAS_Object_Line->ProtectedObject
- ;功 能: 将直线转换成其他类型的以保护数据(同时标记实体以方便恢复)
- ;格 式: (C:OAS_Object_Line->ProtectedObject 直线实体名[ENAME]
- ; 转换模式[字符串"3DFACE"/"TRACE"/"SOLID"]
- ; 转换不准确误差率[实数]
- ; )
- ;返回值: [成功]: 新生成的实体实体名[ENAME]
- ; [失败]: NIL
- ;示 例: (C:OAS_Object_Line->ProtectedObject (car (entsel)) "TRACE" 1000)
- ; =><Entity name: xxxxxxxx>
- ;==================================================================================================
- (Defun C:OAS_Object_Line->ProtectedObject (Entity Mode Ratio /
- E08 E10 E11 E62
- Dist 3DF10 3DF11 3DF12
- 3DF13 Data Dist Rtn
- )
- (if (= (type Entity) 'ENAME)
- (setq Entity (entget Entity))
- )
- (if (null (member Mode (list "3DFACE" "TRACE" "SOLID")))
- (setq Mode "3DFACE")
- )
- (if (= (type Ratio) 'STR)
- (setq Ratio (read Ratio))
- )
- (if (> Ratio 1.0)
- (setq Ratio (/ 1.0 Ratio))
- )
- (setq E08 (cdr (assoc 8 Entity))
- E10 (cdr (assoc 10 Entity))
- E11 (cdr (assoc 11 Entity))
- E62 (cdr (assoc 62 Entity))
- Dist (distance E10 E11)
- )
- (if (/= Mode "3DFACE")
- (setq E10 (polar E10 (angle E10 E11) (* Ratio Dist))
- E11 (polar E11 (angle E11 E10) (* Ratio Dist))
- )
- )
- (setq Dist (* Ratio Ratio (distance E10 E11))
- 3DF10 (polar E10 (+ (angle E10 E11) (* 0.5 pi)) Dist)
- 3DF11 (polar E10 (- (angle E10 E11) (* 0.5 pi)) Dist)
- 3DF12 (polar E11 (+ (angle E10 E11) (* 0.5 pi)) Dist)
- 3DF13 (polar E11 (- (angle E10 E11) (* 0.5 pi)) Dist)
- )
- (if (null E62)
- (setq E62 (cdr (assoc 62 (tblsearch "Layer" E08))))
- )
- (setq Data (list (cons 0 Mode)
- (cons 8 "0")
- (cons 10 3DF10)
- (cons 11 3DF11)
- (cons 12 3DF12)
- (cons 13 3DF13)
- (cons 62 E62)
- )
- )
- (if (= Mode "3DFACE")
- (setq Data (append Data (list (cons 70 5))))
- )
- (if (setq Rtn (entmake Data))
- (progn
- (setq Rtn (entlast))
- (vlax-ldata-put Rtn "OASis-Protect-Layer" E08)
- (vlax-ldata-put Rtn "OASis-Protect-Ratio" (rtos Ratio 2 8))
- (entdel (cdr (assoc -1 Entity)))
- )
- )
- Rtn
- )
|