找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 802|回复: 2

[每日一码] 在多个LAYOUTS中修改多个视口(VIEWPORTS)的图层设置

[复制链接]

已领礼包: 19个

财富等级: 恭喜发财

发表于 2019-1-31 20:52:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×



[Actionscript3] 纯文本查看 复制代码
(defun c:tt (/ ad co e el o s vc)
  ;; RJP » 2019-01-23
  ;; Matches viewport properties to all layouts if target has a similar center location
  (setvar 'tilemode 0)
  (cond	((and (setq e (car (entsel "\nPick source viewport with correct layers: ")))
	      ;; Is it a viewport?
	      (= "VIEWPORT" (cdr (assoc 0 (setq el (entget e '("ACAD"))))))
	      ;; Check if there are layer overrides in the selected viewport
	      (vl-remove-if '(lambda (x) (/= (car x) 331)) el)
	      ;; Get the center of the vieport selected
	      (setq vc (cdr (assoc 10 el)))
	      ;; Select all paperspace viewports in drawing and remove the source
	      (ssdel e (setq s (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (69 . 1)))))
	      (setq s (mapcar 'cadr (ssnamex s)))
	 )
	 (setvar 'cmdecho 0)
	 (setq ad (vla-get-activedocument (vlax-get-acad-object)))
	 (setq o (vlax-ename->vla-object e))
	 (foreach x s
	   ;; If the center point is within a fuzz value of 1
	   (cond ((equal vc (cdr (assoc 10 (setq el (entget x)))) 1)
		  ;; Copy the source viewport
		  (setq	co (car	(vlax-invoke
				  ad
				  'copyobjects
				  (list o)
				  (vlax-ename->vla-object (cdr (assoc 330 (entget x))))
				  t
				)
			   )
		  )
		  ;; Matchpprop won't match from tab to tab but will from drawing to drawing .. go figure.
		  (setvar 'ctab (cdr (assoc 410 el)))
		  ;; Make sure we're in paperspace
		  (command "_.pspace")
		  ;; Ugly but seems to work
		  (command "_.matchprop" (vlax-vla-object->ename co) x "")
		  ;; Delete the copied viewport
		  (vla-delete co)
		  ;; Print the tab name
		  (print (cdr (assoc 410 el)))
		 )
	   )
	 )
	 (setvar 'cmdecho 1)
	)
  )
  (princ)
)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 5295个

财富等级: 富甲天下

发表于 2019-1-31 22:14:24 | 显示全部楼层
好代码!真是值得好好学习一下。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 6468个

财富等级: 富甲天下

发表于 2019-1-31 23:38:26 | 显示全部楼层
学习一下。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-6-14 13:58 , Processed in 0.170945 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表