抱歉,斗士,把所有的代码都和我正在写的另一个程序混淆了。。。上面的代码适用于我发布的绘图示例。
假设以下数字是您使用的dimscale。
0.67
1
1.33
2
所以当你测试代码的时候。使用这两个数字中的任何一个
HTH公司
效果很好!然而,它并没有涵盖我使用的所有比例,尤其是当它缩放柱脚时,当我选择时,柱脚会变短。例如,5 dimscale。下面是我的一段代码,它查找dimscale并分配一个变量。
(defun c:mit
(/ _LockorXref _pledit _carcadr approvedscales scale pscale nscale ent typ pl plt)
(vl-load-com)
(defun _LockorXref(table/ a b)
(setq b "")
(while (setq a (tblnext table (null a)))
(if (= 4 (logand 4 (cdr (assoc 70 a))))
(setq b (strcat b (cdr (assoc 2 a)) ","))
)
) b
)
(defun _pledit(ex ne e / ext)
(setq ext (abs (- (cadr ex)(cadr ne))))
(if (< (car ex) (car ne))
(append
(_carcadr (vlax-curve-getPointAtDist e ext))
(_carcadr
(vlax-curve-getPointAtDist
e
(- (vlax-curve-getDistAtParam
e
(vlax-curve-getEndParam
e))
ext))))
(progn (setq ang (angle
(setq sp (vlax-curve-getStartPoint
e))
(setq ep (vlax-curve-getEndPoint
e))))
(append (_carcadr (polar sp (+ ang pi) ext))
(_carcadr (polar ep ang ext))))
)
)
(setq approvedscales
'((0.125 -5.25) (0.25 -4.5) (0.333 -4.002)(0.5 -3.0) (0.667 -1.98) (1.00 0.00) (1.25 1.50)
(1.33 1.98) (2.00 6.0)(2.5 9.0) (3.75 16.50) (5.00 24.0) (6.25 31.50) (7.5 39.0)
(8.75 46.50) (10 54.0) (11.25 61.50) (12.5 69.0)
)
_carcadr (lambda (x) (list (car x) (cadr x)))
pscale nil)
(if (and (setq scale (getvar 'dimscale))
(assoc scale approvedscales)
(setq pl (ssadd)
ss (ssget "_X"
(list
'(-4 . "<or")
'(-4 . "<AND")'(0 . "INSERT")
'(-4 . "<not") (cons 8 (_LockorXref "LAYER" )) '(-4 . "not>")
'(-4 . "<not") (cons 2 (_LockorXref "BLOCK" )) '(-4 . "not>")
'(-4 . "AND>")
'(-4 . "<AND") '(0 . "LWPOLYLINE") '(8 . "SPRKVIEW")
'(-4 . "AND>") '(-4 . "OR>"))
)
))
(progn
(repeat (setq i (sslength ss))
(setq ent (ssname ss (setq i (1- i))))
(cond
((eq (setq typ(cdr(assoc
0
(entget
ent))))
"INSERT")
(if (null pscale)
(setq pscale
(abs (cdr (assoc 41 (entget ent))))))
(mapcar
'(lambda (j)
(vlax-put
(vlax-ename->vla-object
ent)
j
scale))
'("XScaleFactor"
"YScaleFactor"
"ZScaleFactor"))
)
((eq typ "LWPOLYLINE")
(setq pl (ssadd ent pl)))))
(if (and pscale (ssname pl 0))
(progn
(setq pscale (assoc pscale approvedscales))
(setq nscale (assoc scale approvedscales))
(repeat (sslength pl)
(setq plt(vlax-ename->vla-object
(setq e_ (ssname pl
0))))
(vla-put-ConstantWidth
plt
(* scale
2.0))
(if (car (setq cord (_pledit
pscale
nscale
e_)))
(vlax-putplt 'coordinates cord))
(ssdel (ssname pl 0) pl))
)
)
)
)
(princ)
)
这些是我们工作中唯一使用的尺度。在这里,您可以看到我们使用的所有DIMSCALE。此外,我正在开发的程序应该选择模型空间中的所有块并缩放它们,但我可以轻松地更改代码以选择所有块,而不仅仅是一个块。
***编辑***
哦,我不确定你会把它放在代码中的什么地方,或者你会改变什么,但是我们在柱脚上处理两种不同的宽度。支线为2.5英寸,干线为3.5英寸,比例为1/8英寸。此外,在更改这些块的地方(模型空间),在锁定层上也有x-ref,因此可能也需要以某种方式合并。
检查
我可以显示在哪里和什么斗殴,宽度没有什么大不了的,我不明白的是对外部参照对象的引用,你想外部参照文件上的块也更新吗?这将是一个很好的例子,[我更喜欢在这种情况下使用注释性块,在这种情况下,甚至外部参照也会立即更新]但您之前提到的您正在使用的软件不具备这种功能。
你能提供更多关于这个问题的信息吗?
哦,不,不。如果我听起来很困惑,很抱歉。我的意思是,我也有X-Ref的,在同一个空间,作为块正在被改变。我试着稍微修改代码,这样它就不会只查找“BLOCK1”插入,而是查找模型空间中属于插入的所有内容。当我试着运行例程时,它在外部参照上拾取,并说某个对象位于锁定层上,无法完成例程。
基本上,我需要它来查找和缩放模型空间中实际在图形中(而不是在外部参照中)的任何块。 你是如何选择区块的?使用ssget?您只使用DXF值还是同时使用VLA方法?很抱歉,您没有发布任何代码-因此我可以向您提供很多替代方案,但许多可能效率低下(取决于您的代码)。
编辑:对不起,我今天失明了,你在使用pBe的代码。
“最简单”的方法可能是使用ssget的“:L”选项来禁止在锁定层上选择实体。否则,您需要检查块定义,以确定它们是否为外部参照(例如,定义代码1将具有路径,vla对象具有IsXref特性)。
我认为最有效的方法可能是生成非外部参照的块名列表(通过遍历块定义表vla get Blocks of active document,或tblnext)。然后将其组合成逗号分隔的字符串,以包含在ssget的过滤器列表中。这样,您只需要检查每个块定义一次。如果选择后在循环内进行检查,则会多次检查同一定义。
我查看了“:L”,但随后我必须在所有内容周围拖动一个窗口来选择我的块等等。我希望它能够选择所有内容 How are you selecting the blocks? Using ssget? Are you only working with DXF values or also VLA methods? Sorry, you've not posted any code - so there's quite a few alternatives I could throw at you, many might be inefficient though (depending on your code).
Edit: Sorry I'm blind today , you're using pBe's code.
The "easiest" way might be to use ssget's ":L" option to disallow selection of entities on locked layers. Otherwise you need to check the block definitions to find out if they're xrefs (e.g. the definitions code 1 would have a path, the vla object has a IsXref property).
I think the most efficient way might be to generate a list of block names which aren't xrefs (by going through the block definition table vla-get-Blocks of active document, or tblnext). Then combine that into a comma seperated string for inclusion in ssget's filter list. That way you only need to check each block definition once. If you check inside the loop after selecting, you'll check the same definition multiple times.
I looked into ":L", but then I would have to drag a window around everything to select my blocks and such. I want it to be able to just select everything for me. I tried combining "_X:L" and a few other combinations, but I guess ssget filters don't allow that setup.
Ultimately, my master code will work in such a way that anytime I need to change the scale of a drawing (ie draw everything to 1/8" originally, but the sheets end up needing to be 3/32", I can just change the scale of the drawing and it will scale everything for me automatically), everything gets updated to the new scale with one click. Currently, everything is based around dimscale. When you change the dimscale, it sets the fillet radius and lts. Since I know that dimscale is a constant value saved next time you open the drawing, I have it setup so that when you open the drawing, it reads the dimscale then sets my variables for thehfscale, lts, filletrad, and some other custom variables.
I really like pBe's code, I just need a few adjustments to it to work the way I need it to. Find and scale ALL blocks and plines on a particular layer in model space to any of the listed approved scales I have above. Right now, the scaling of the plines doesn't work on every scale, but not sure why. I will look into it brawleyman, dont have CAD with me right now, question though, if the routine is not limited to a specific block....
That statement wont be applicable anymore? or the rest of the blocks are the same size as the orignal block (in terms of geometry i mean), if not we may have to use a different approach, as the previous code will compute the length of the pline with a specific increment (by a factor of 1.98 ) based on a 12" block.
页:
1
[2]