Class Module to create blocks

Discussion in 'AutoCAD' started by Dale Levesque, Feb 20, 2004.

  1. I currently use a class library that contains various class modules used to
    draw shapes in AutoCAD. They currently create LWPolyline entities but I'd
    like to modify them to create block insertions instead. The reason for this
    is that there may be several hundred instances of the LWPolyline entities
    created by a given class module in a drawing. By making it a block insertion
    instead, If the end user has to modify a specific shape because the customer
    has decided that a dimension should change the user can simply redefine the
    block in the drawing rather than having to modify each individual LWPolyline
    created by that class module.

    Here's the tricky bit. If we consider the simplest class module having the
    following properties:

    Length, Double
    Width, Double
    RotationAngle, Double
    Mirrored, Boolean

    (I fully intend to remove these 2 latter properties when converting the
    object to a block insertion.)

    If my application creates a block insertion name MyInsert with the following
    values:

    Length, 5.0
    Width, 2.5
    RotationAngle, 0
    Mirrored, False

    then any block insertion created by the same class module with any other
    values than these would require a different name so that these insertions
    would not be changed when the user redefined the block definition for
    MyInsert.

    I'm thinking of creating the first insert as MyInsert1 while adding the
    class property values (stored in a collection) into the dictionary. Then I
    can check the dictionary everytime the class module creates an insertion
    object to see if it has different properties than any previous entry with a
    'MyInsert' prefix. If any property is different I would then increment the
    suffix of the Block name and create another dictionary entry.

    Question:

    Any suggestions? Is there a better or easier way to do this that anyone can
    see.
    Is the dictionary the right place to do this?


    Best regards,

    Dale-
     
    Dale Levesque, Feb 20, 2004
    #1
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.