天花板网格布局的LISP
你好我只是想知道是否有人编写了lisp例程,可以在闭合多段线内生成2x4天花板网格布局?
我过去经常使用自定义填充图案(一个用于2x2,一个用于2x4,等等)。 good’ol Hatch有什么问题
_用户
双重的
HP原始模式5 如果您遵循老派规则,即主边框平铺必须大于平铺尺寸的1\2,则必须在填充边框之前进行一些手动计算和调整。然后必须将舱口移到适当位置。
这来自一个旧的例程,该例程生成网格线,但不修剪边界外多余的线。它会自动调整边框平铺
方向为48“轴方向“X”或“Y”
;;; 2 X 4 Ceiling Tile Grid
;;;ARG -> Border_Point_List Direction-X/Y
;;;RET -> nil
(defun ct-2x4 (pl dir / nx xx ny xy xs ys xc yc xq yq
xt yt xr yr i xa ya)
(setq nx (apply 'min (mapcar 'car pl))
xx (apply 'max (mapcar 'car pl))
ny (apply 'min (mapcar 'cadr pl))
xy (apply 'max (mapcar 'cadr pl))
xs (- xx nx)
ys (- xy ny)
xc (+ nx (* xs 0.5))
yc (+ ny (* ys 0.5)))
(if (= dir "X")
(setq xt 48. yt 24.)
(setq xt 24. yt 48.))
(setq xq (fix (/ xs xt)) xr (- xs (* xq xt))
yq (fix (/ ys yt)) yr (- ys (* yq yt)))
(if (< xr (* xt 0.25)) (setq xc (+ xc (* xt 0.5)) xa T) (setq xa nil))
(if (< yr (* yt 0.25)) (setq yc (+ yc (* yt 0.5)) ya T) (setq ya nil))
(setq i 1)
(entmake (list (cons 0 "LINE")
(list 10 nx yc 0)
(list 11 xx yc 0)))
(setq i 1)
(while (<= (+ yc (* yt i)) xy)
(entmake (list (cons 0 "LINE")
(list 10 nx (+ yc (* yt i)) 0)
(list 11 xx (+ yc (* yt i)) 0)))
(setq i (1+ i)))
(setq i 1)
(while (>= (- yc (* yt i)) ny)
(entmake (list (cons 0 "LINE")
(list 10 nx (- yc (* yt i)) 0)
(list 11 xx (- yc (* yt i)) 0)))
(setq i (1+ i)))
(entmake (list (cons 0 "LINE")
(list 10 xc ny 0)
(list 11 xc xy 0)))
(setq i 1)
(while (<= (+ xc (* xt i)) xx)
(entmake (list (cons 0 "LINE")
(list 10 (+ xc (* xt i)) ny 0)
(list 11 (+ xc (* xt i)) xy 0)))
(setq i (1+ i)))
(setq i 1)
(while (>= (- xc (* xt i)) nx)
(entmake (list (cons 0 "LINE")
(list 10 (- xc (* xt i)) ny 0)
(list 11 (- xc (* xt i)) xy 0)))
(setq i (1+ i)))
(prin1))
玩得开心-大卫
谢谢你,大卫,但我运行它有困难。所以我复制了代码并将其保存为lisp文件,加载它,然后尝试从命令行运行它——但它只是说command not foud。 出现以下错误:
错误:无函数定义:PL 我是pBe的,我总是用舱口。这么简单。我甚至把它作为一个宏从工具选项板上取下来,所以你可以直接点击边界和bam,天花板网格。
我以前使用hatch,唯一的问题是我无法指定中心点,尤其是对于形状不规则的房间,另一个问题是我必须爆裂/分解图案填充,因为照明设备符号无法捕捉到图案填充。
我以前做的是我有两种模式,一种是2x4,另一种是4x2,我会根据我喜欢的方向来选择。我想我必须回到舱口。 轻松修复。只需使用UCS命令旋转用户坐标系即可轻松对齐图案填充。然后,可以使用“图案填充原点”选项定位精确的原点,以便天花板网格位于正确的位置。使用OSNAPHATCH变量可以捕捉填充图案。如果使用工具选项板,您可以拥有一个灯具块库,当您插入它们时,可以将其预设为所需的任何图层,并可以在插入点上旋转,以及工具选项板提供的许多其他选项。 换上你的西装
;; CG.lsp
;; || This routine draws ceiling grid inside the specified boundary ||
;; fixo () 2009 * all rights released
;; 3/10/09
;; edited 3/23/09
;; edited 2/18/12
;;=================================== code start =================================;;
;; make layer if this does not exist
(defun _make_layer (lname
col
ltype
lweight
plotmode
plotstyle
desc
/
layer_obj
pstyle)
(if (not (tblsearch "LAYER" lname))
(progn
(entmake
(list '(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 lname)
'(70 . 0)
(cons 62 col)
(cons 6 ltype)
(cons 290 plotmode)
(cons 370 lweight)));-3
;; Create layer description and set plot style
(setq layer_obj (vla-item
(vla-get-layers
(vla-get-activedocument (vlax-get-acad-object)))
lname)
)
(if (not (eq "" desc))
(if (>= (atof (getvar "acadver")) 16.1)
(progn
(vla-put-description layer_obj desc)
)
)
)
(vl-catch-all-apply
(function (lambda ()
(if (= (getvar "pstylemode") 0)
(vla-put-plotstylename layer_obj pstyle)
)))
)
(vlax-release-object layer_obj)
)
(princ (strcat "\n --- Layer " "\"" lname "\"" " already exist ---")
)
)
)
(defun C:CG (/ *error* ang bd bdobj cell cl hatch hn osm pnt pt); CG - celing grid
;; error trapping function
(defun *error* (msg)
(vla-endundomark
(vla-get-activedocument (vlax-get-acad-object)))
(if hn
(setvar 'HPNAME hn))
(if ht
(setvar 'HPGAPTOL ht))
(if osm
(setvar 'OSMODE osm))
(if cl
(setvar 'CECOLOR cl))
(if cc
(setvar 'CLAYER cc))
(setvar 'CMDECHO 1)
(if msg
(prompt (strcat "\n\t\t *** Error occured: ***\n" msg))
)
)
;; convert radians to degrees
(defun rtd (a)
(* (/ a pi) 180)
)
;;========================= main part =======================;;
(vla-endundomark
(vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
(setq hn (getvar 'HPNAME))
(setq ht (getvar 'HPGAPTOL))
(setq osm (getvar 'OSMODE))
(setq cl (getvar 'CECOLOR))
(setq cc (getvar 'CLAYER))
(setvar 'OSMODE 0)
(setvar 'CMDECHO 0)
(_make_layer "A-CLNG-2x2" ;layer name
110 ;color index
"Continuous" ;linetype
-3 ;lineweight "Default" = -3
1 ; plottable
"Very Light Grey" ;plot style (ignore if does not exist)
"Ceiling Tile Pattern_ 12 x 12 Glued" ;layer description
)
(setvar 'CLAYER "A-CLNG-2x2")
(initget 6)
(setq cell (getreal "\nEnter a tile size <4> : "))
(or cell (setq cell 4));---> change the default tile size you need
(alert "The room boundary must be visible completely\non screen before you will pick a point inside")
(setq pt (getpoint "\nSpecify the point inside the boundary near of the longest side: "))
(setvar 'OSMODE 128)
(setq pnt (getpoint pt "\nSpecify the point perpendicularly to this side: "))
(setq ang (rtd (+ (/ pi 4) (angle pnt pt))))
(setvar 'CECOLOR "BYLAYER")
(setvar 'HPGAPTOL 0.1)
(setvar 'HPNAME "ANSI37")
(if (not
(vl-cmdf "._-hatch" pt "_P" "" cell ang ""))
(progn
(alert "Something wrong with creating hatch...")
(exit)
)
(vl-cmdf "._draworder" "_L" "" "_B" )
)
(setq hatch (entlast))
;(command "._chprop" hatch "" "LA" "A-CLNG-2x2" "")
;;; (command "._explode" hatch);; uncomment this line if you want to explode the hatch
(*error* nil)
)
(prompt "\n --- Start command with \"CG\" or \"cg\" ---")
(princ)
(vl-load-com)
(princ)
;;=================================== code end =================================;;
~'J'~
这不是命令行调用。您需要提供点列表和方向参数。
(ct-2x4 '((-249.0 171.0 0.0)
(-249.0 -201.0 0.0)
(15.0 -201.0 0.0)
(15.0 -132.0 0.0)
(180.0 -132.0 0.0)
(180.0 246.0 0.0)
(-93.0 246.0 0.0)
(-93.0 171.0 0.0)
(-249.0 171.0 0.0))
"Y")
点列表来自附着的dwg。
-大卫
CGRID。图纸
页:
[1]
2