Covert Polyline into Block

Discussion in 'AutoCAD' started by Feng Yang, Sep 17, 2003.

  1. Feng Yang

    Feng Yang Guest

    Hello Everybody,



    What I try to accomplish is convert every polyline object into an individual
    block. Every single part in our CAD drawings is drawn as a polyline.



    If I use the standard AutoCAD block command, I can pick an insert point, an
    object, and covert that object into a block. How can automatic the above
    process?



    The following is what I had tried so far.



    Lisp:

    I wrote a lisp program to automatic the convert process. I did create a
    block by picking the specific polyline, but my original object was gone
    after. Is there any variable I can change to covert the polyline to block
    without erase the original object?



    Command: -block



    Enter block name or [?]: test

    Specify insertion base point:

    Select objects: 1 found



    VBA:

    I try to copy the object into the block by using:

    varDestEnts = ThisDrawing.CopyObjects(objSourceEnts, objBlock)

    I did get a block, but the original polyline object still there.



    Really appreciate any suggestion or input, thanks.



    Feng
     
    Feng Yang, Sep 17, 2003
    #1
    1. Advertisements

  2. Without seeing all of your code, this is my best guess:

    varDestEnts = ThisDrawing.CopyObjects(objSourceEnts, objBlock)
    objSourceEnts.Delete
    ___________________________
    Mike Tuersley
    AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Sep 17, 2003
    #2
    1. Advertisements

  3. Feng Yang

    Feng Yang Guest

    Thanks, Mike.

    Your guess is quite right. But the problem still there, insead of covert the
    polyline object. The code create a block based on the polyline object, and
    erase the original polyline object.

    What I really want to accomplish is: pick the polyline objcet, convert it
    into a block, and the original polyline object will be replace by the block
    right away. Just like what we do by the standard AutoCAD "Block" command.
    Any idea?

    Thanks.

    Feng
     
    Feng Yang, Sep 17, 2003
    #3
  4. well, since you are defining the new block's insertion point, just
    insert it. It would look something like:

    Sub Ch10_InsertingABlock()
    ' Define the block
    Dim objSourceEnts As AcadObject
    Dim blockObj As AcadBlock
    Dim blockRefObj As AcadBlockReference
    Dim insertionPnt(0 To 2) As Double
    insertionPnt(0) = 0
    insertionPnt(1) = 0
    insertionPnt(2) = 0
    Set blockObj = ThisDrawing.Blocks.Add _
    (insertionPnt, "MyBlock")

    '...do your selecting...

    varDestEnts = ThisDrawing.CopyObjects(objSourceEnts, objBlock)
    objSourceEnts.Delete

    ' Insert the block
    insertionPnt(0) = 2
    insertionPnt(1) = 2
    insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
    (insertionPnt, "MyBlock", 1#, 1#, 1#, 0)
    End Sub

    This is a modified version of the example found in the help file.

    ___________________________
    Mike Tuersley
    AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Sep 18, 2003
    #4
  5. Feng Yang

    Deeb Dahdouli

    Joined:
    Jan 24, 2015
    Messages:
    2
    Likes Received:
    0
    Hi all,

    I have the same problem, I want to convert each polyline to a block, so when I edit the block all the blocks are changed together, I think the lisp code is usefull for me but I am not expert in lisp. How can I load the lisp code and what is the command to use it.

    Thanks in advance.
     
    Deeb Dahdouli, Jan 24, 2015
    #5
  6. Feng Yang

    Terminator

    Joined:
    Feb 12, 2013
    Messages:
    37
    Likes Received:
    2
    There is no need to do that. You edit one of the blocks using the Block Editor then save the changes. When you pop back into your drawings all the other blocks will now display the changes as well.
     
    Terminator, Feb 6, 2015
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.