Author Topic: How to change all the width of the lwpolyline in many block.  (Read 2534 times)

0 Members and 1 Guest are viewing this topic.

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
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
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

DEVITG

  • Bull Frog
  • Posts: 479
Re: How to change all the width of the lwpolyline in many block.
« Reply #1 on: June 15, 2008, 06:53:16 PM »
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 .??
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

FengK

  • Guest
Re: How to change all the width of the lwpolyline in many block.
« Reply #2 on: June 15, 2008, 10:30:04 PM »
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:

Code: [Select]
(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)
)














Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to change all the width of the lwpolyline in many block.
« Reply #3 on: June 16, 2008, 01:14:09 AM »

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 ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: How to change all the width of the lwpolyline in many block.
« Reply #4 on: June 17, 2008, 09:51:40 AM »
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!

http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: How to change all the width of the lwpolyline in many block.
« Reply #5 on: July 24, 2008, 07:29:14 AM »
Code: [Select]
(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)
)

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: How to change all the width of the lwpolyline in many block.
« Reply #6 on: July 24, 2008, 08:22:28 AM »
Thank you, Evgeniy, it do work.
Thx.
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)