Old Block to New Block

Discussion in 'AutoCAD' started by VikCAD04, Oct 5, 2004.

  1. VikCAD04

    VikCAD04 Guest

    I have a dilemma, my company has been using a really bad revision block through out all of our drawings, basically, the attributes have the same tag, same prompt and same default.

    So for me to write a lisp that automatically fills in the revision description and signs it, is almost impossible, since i can't find a way to check each rev in order.

    So what my plan is, to get rid of the old rev-block, and insert the new with different tags, and the second part will be to insert the new information.
    Now that i confused all fo you, i thought of doing something like this:
    Burst the old block
    copy all the information that is found at the insertion points of the bursted block.
    insert the new block, and paste the information in that order.

    Before i get going on it, does anyone know of a simpler way?
    I will be dealing with a large number of drawings so something that is simple for a regular user will also have to be considered.

    Thanks for all your help,
    Viktor
     
    VikCAD04, Oct 5, 2004
    #1
  2. VikCAD04

    fengk Guest

    I think you should be able to modify the block definition without exploding it.
    Get the definition of the block, which is a collection, and process the attribute definition object.
     
    fengk, Oct 6, 2004
    #2
  3. VikCAD04

    VikCAD04 Guest

    what do you mean "get the definition of the block"?
    how would i do that, i'm not a lisp expert.
    Thanks for quick response.
    Viktor
     
    VikCAD04, Oct 6, 2004
    #3
  4. VikCAD04

    fengk Guest

    Try excute the following code.

    (setq doc (vla-get-activedocument (vlax-get-acad-object))
    colBlk (vla-get-blocks doc)
    )
    (setq blkName "YourBlockName")
    (setq blkDef (vla-item colBlk blkName))
    ;;; blkDef contains the definition of the block.
    (vlax-for obj blkDef
    (vlax-dump-object obj t)
    )


    You can use (vla-put-xxx) to change objects' properties.
     
    fengk, Oct 6, 2004
    #4
  5. VikCAD04

    VikCAD04 Guest

    Thanks,
    although that looks complex and I have never used the vla.. functions, i'll have to read up on that.
    but could you just explain the basics of it in a couple of words?
    my understanding is you get all the properties and all the definitions of the block into the blkdef, so in order for me to change it, i would need to find something that is different on all the attributes, and use it to separate between them??

    Thanks for your help,
    Viktor
     
    VikCAD04, Oct 6, 2004
    #5
  6. VikCAD04

    fengk Guest

    In the code below, substitute "YourBlockName" with the name of block you want to
    modify. Then load the below and issue command TEST.

    (defun C:TEST (/ doc colBlk blkName blkDef)
    (setq doc (vla-get-activedocument (vlax-get-acad-object))
    colBlk (vla-get-blocks doc)
    )
    (setq blkName "YourBlockName")
    (setq blkDef (vla-item colBlk blkName))
    ;;; blkDef contains the definition of the block.
    (vlax-for obj blkDef
    (vlax-dump-object obj t)
    )
    (princ)
    )


    You'll see lot of information returned. Look for something like what's shown below.
    This has the information of an attribute definition. From here you can change those
    properties. For example (vla-put-TagString objAttDef "New_Tag") will change the attribute's
    tagstring from "FROM-TO" to "New_Tag". etc. See if these make sense to you.


    ; IAcadAttribute: AutoCAD Attribute Interface
    ; Property values:
    ; Alignment = 10
    ; Application (RO) = #<VLA-OBJECT IAcadApplication 00b9d604>
    ; Backward = 0
    ; Constant = 0
    ; Document (RO) = #<VLA-OBJECT IAcadDocument 01045290>
    ; FieldLength = 0
    ; Handle (RO) = "AA5FA74200DF06E4"
    ; HasExtensionDictionary (RO) = 0
    ; Height = 0.085
    ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0a67df54>
    ; InsertionPoint = (-0.303571 -0.137939 0.0)
    ; Invisible = 0
    ; Layer = "0"
    ; Linetype = "BYLAYER"
    ; LinetypeScale = 1.0
    ; Lineweight = -1
    ; Mode = 0
    ; Normal = (0.0 0.0 1.0)
    ; ObjectID (RO) = 2130066720
    ; ObjectName (RO) = "AcDbAttributeDefinition"
    ; ObliqueAngle = 0.287979
    ; OwnerID (RO) = 2130066680
    ; PlotStyleName = "ByLayer"
    ; Preset = 0
    ; PromptString = "Description"
    ; Rotation = 0.0
    ; ScaleFactor = 1.0
    ; StyleName = "RSR"
    ; TagString = "FROM-TO"
    ; TextAlignmentPoint = (-5.32907e-015 -0.0954395 0.0)
    ; TextGenerationFlag = 0
    ; TextString = "FROM-TO"
    ; Thickness = 0.0
    ; TrueColor = #<VLA-OBJECT IAcadAcCmColor 0a67e110>
    ; UpsideDown = 0
    ; Verify = 0
    ; Visible = -1
    ; Methods supported:
    ; ArrayPolar (3)
    ; ArrayRectangular (6)
    ; Copy ()
    ; Delete ()
    ; GetBoundingBox (2)
    ; GetExtensionDictionary ()
    ; GetXData (3)
    ; Highlight (1)
    ; IntersectWith (2)
    ; Mirror (2)
    ; Mirror3D (3)
    ; Move (2)
    ; Rotate (2)
    ; Rotate3D (3)
    ; ScaleEntity (2)
    ; SetXData (2)
    ; TransformBy (1)
    ; Update ()
     
    fengk, Oct 6, 2004
    #6
  7. VikCAD04

    VikCAD04 Guest

    I see, thanks, let me mess with it, i've never seen that function used or in any lisp tutorial.
    it's pretty powerful.

    Thanks,
    Viktor
     
    VikCAD04, Oct 6, 2004
    #7
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.