TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: qjchen on June 15, 2008, 06:17:08 AM
-
There are many lwpolyline in many block, I need to change all the polyline width to a new one, just like "30".
I'm unfamiliar with sub entity, could you help me? Thank you very much.
:-D
-
There are many lwpolyline in many block, I need to change all the polyline width to a new one, just like "30".
I'm unfamiliar with sub entity, could you help me? Thank you very much.
:-D
Can you upload the dwg .??
-
There are many lwpolyline in many block, I need to change all the polyline width to a new one, just like "30".
I'm unfamiliar with sub entity, could you help me? Thank you very much.
:-D
block definition is like a collection, so you can use vlax-for to loop through the subentities. say you have a block named "BlkName1" and doc is the document object:
(setq colBlk (vla-get-blocks doc)
blkdef (vla-item colBlk "BlkName1")
)
(vlax-for obj blkDef
(if (eq (vla-get-objectname obj) "AcDbPolyline"))
(vla-put-width obj 30)
)
-
yuanqiu ,
The code Kelie posted should be fine for block instances.
... or do you want to change the original block definition in the BlockDefinitionTable as well ??
-
To DEVITG
Now I have no such file, I will try to upload it later.
To Kelie
Your code will help me greatly, I think this must be the right and quick way to solve the question.
To Kerry Brown
I dont need to change the original block definition in the BlockDefinitionTable:)
Thank you all very much!
-
(defun c:test (/ s)
(vl-load-com)
(princ "\n Select the block with a polyline")
(if (and (setq s (ssget "_+.:S" '((0 . "insert"))))
(setq s (cdr (assoc 2 (entget (ssname s 0)))))
) ;_ and
(progn
(vlax-for
o
(vla-item (vla-get-blocks
(vla-get-ActiveDocument (vlax-get-acad-object))
) ;_ vla-get-blocks
s
) ;_ vla-item
;;(setq o (vla-item (vla-item (vla-get-blocks (vla-get-ActiveDocument(vlax-get-acad-object))) s)0))
(if (= (vla-get-objectname o) "AcDbPolyline")
(vl-catch-all-apply 'vla-put-ConstantWidth (list o 30.))
) ;_ if
) ;_ vlax-for
(foreach x (mapcar (function cadr)
(ssnamex (ssget "_x" (list (cons 2 s))))
) ;_ mapcar
(vla-update (vlax-ename->vla-object x))
) ;_ foreach
) ;_ progn
) ;_ if
(princ)
)
-
Thank you, Evgeniy, it do work.
Thx.