Setting an attribute value in an unopened drawing.

Discussion in 'AutoCAD' started by David Kozina, Jun 29, 2004.

  1. David Kozina

    David Kozina Guest

    When I open a drawing, I have a routine that checks the filename. If it
    identifies the drawing as a detail and also finds a detail title bubble, it
    will plug in the appropriate value in the bubble attribute.

    Example: Say the detail drawing has a name SE501-C2.dwg. When it is
    opened, the Title Bubble gets set to "C2" - no matter what it may have been
    set to before.

    This works exactly as I want it to do.

    My question is, can I accomplish this 'remotely'? - i.e. Setting an
    attribute value without the additional step of opening the drawing in
    AutoCAD?

    I've heard much talk of ObjectDBX as a means to do this, but does one need
    to be a developer in order to have access to those tools? I haven't been
    able to find much info, nor practical examples in the Help Files,
    (particularly any that use VLisp), nor at the autodesk website. Any
    directions to the proper place to search?

    Or <narrowing eyes> are there other sneaky ways to accomplish this?
    (I wouldn't mind opening the drawing, via file open or a script, and just
    letting the startup routine handle it as usual - but then the calling
    routine in the original drawing would lose control of what happens after
    that, correct?)

    Open to any/all suggestions.

    Best regards,
    David Kozina

    PS While I'd love to register as a developer, it is just not within my
    reach at the present time.
     
    David Kozina, Jun 29, 2004
    #1
  2. David Kozina

    ECCAD Guest

    My 2 cents:
    I think ObjectDBX would do the job, but you still have to 'call' it for use - possibly through VB or VBA. Might be just as easy to add a file-open at the end of a script, and feed it the drawing path (dwgprefix) and drawing name (dwgname -4), and open the original drawing at the end ?

    Bob
     
    ECCAD, Jun 29, 2004
    #2
  3. David Kozina

    David Kozina Guest

    Bob,

    A little more clarification on what I'm trying to do...

    The drawing I'm trying to adjust 'remotely' will be xreffed into the drawing
    I'm calling the routine from.

    Basically, I'm only looking to modify the detail drawing slightly (as
    explained earlier) before I xref it in.

    I'd like to avoid a labyrinth-like procedure of closing original drawing,
    opening detail drawing, closing it, and then re-opening the original
    drawing, and then xreffing in the detail drawing. My brain hurts just
    thinking about that. <shudder>

    If ObjectDBX is the answer, where do I get started? (Assuming I can.)

    Or might there be another solution?

    Best regards,
    David Kozina


    use - possibly through VB or VBA. Might be just as easy to add a file-open
    at the end of a script, and feed it the drawing path (dwgprefix) and drawing
    name (dwgname -4), and open the original drawing at the end ?
     
    David Kozina, Jun 29, 2004
    #3
  4. David Kozina

    ECCAD Guest

    <<If ObjectDBX is the answer, where do I get started? (Assuming I can.)>>
    I'd check out VBA first.
    Type: VBAIDE at the command prompt.

    Bob
     
    ECCAD, Jun 29, 2004
    #4
  5. David Kozina

    Jeff Mishler Guest

    Hi David, this should get you started. This is from a routine I wrote to
    import LayoutTabs form another drawing. I've ripped out most of the
    irrelevant code, but the rest is what is required for what you want.

    Good Luck,
    Jeff

    Code:
    ;source is a valid path & dwg name
    (defun imp_layouts (source / *acad* doc l_import odbx Doctest
    path lays l_list)
    (vl-load-com)
    (setq *acad* (vlax-get-acad-object)
    doc (vla-get-activedocument *acad*))
    ;;**** Check if source file is open
    (vlax-for oDoc (vla-get-documents *acad*)
    (if (= (vla-get-fullname oDoc) source)
    (setq Doctest t)))
    (if (and (not Doctest) (findfile source))
    (progn ;; Ensure that ObjectDBX is available
    (if (> (atoi (getvar "AcadVer")) 15)
    (setq oDBX (vla-GetInterfaceObject
    *acad* "ObjectDBX.AxDbDocument.16"))
    (progn
    (if (not (vl-registry-read
    "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"))
    (startapp "regsvr32.exe"
    (strcat "/s \"" (findfile "axdb15.dll") "\""))
    );;if
    (setq oDBX (vla-GetInterfaceObject
    *acad* "ObjectDBX.AxDbDocument"))
    );;progn
    );;if
    (vla-open oDBX source);; "opens" source for our use
    
    ; do your stuff here re: obtaining and modifying the attribute
    ; note that you must cycle through the tab that it will be in to obtain it,
    ; no selection sets allowed in ObjectDBX
    
    (vla-saveas oDBX (vla-get-name oDBX));must use SaveAs, Save not implemented
    (vlax-release-object oDBX);; we're done with it
    );progn
    (progn
    (if doctest
    (princ "\nYou tried to use a file in use by Autocad, please close it and
    try again....")
    (princ "\nSource file not found, please try again....")
    );;if
    );;progn
    );if
    (princ);; exit quietly
    )
    
     
    Jeff Mishler, Jun 29, 2004
    #5
  6. David Kozina

    David Kozina Guest

    Jeff,

    Thanks for the help!

    My eyes were glazing wandering about the VBAIDE.
    I gotta learn it, me thinks, but it still seems too intimidating...
    Someday...

    I will review your code to see how I can apply the principles therein...
    On the surface it looks just like what I'm needing.

    Best regards,
    David Kozina


     
    David Kozina, Jun 29, 2004
    #6
  7. David Kozina

    David Kozina Guest

    By means of Jeff's code sample, I was, amazingly enough for me, able to
    actually set the attributes to the text I needed. (Huzzah!)

    But, (there's always a but), as it turns out, the two attributes I'm needing
    to change happen to be Middle Center Justified and Bottom Right Justified.
    Yet when they are modified via ObjectDBX, their justification doesn't seem
    to be taken into consideration, and thus they just 'ain't right' when the
    detail is xreffed in.

    Any ideas?

    At any rate, many, many thanks, Jeff, for the code you posted!

    Best regards,
    David Kozina
     
    David Kozina, Jun 30, 2004
    #7
  8. David Kozina

    Jeff Mishler Guest

    You are quite welcome! I'm glad it could help you.

    As to the attributes' justification, how are you modifying them?
    Care to post what you used, both code & sample drawings? I ask because I
    just created a couple dummy drawings, one with a number of attributes with
    varying justifications, then xreffed that one into the other and they look
    fine.....

    Jeff
     
    Jeff Mishler, Jun 30, 2004
    #8
  9. David Kozina

    Jeff Mishler Guest

    Scratch that! I was just playing with this a bit more and after activating
    grips in blocks I can see what has happened. The original InsertionPoint
    property is taking precedence over the AlignmentPoint property......now, how
    to fix this....
     
    Jeff Mishler, Jun 30, 2004
    #9
  10. David Kozina

    Jeff Mishler Guest

    Well, I just found a post from Tony TRanzillo in the VBA newsgroup that
    addresses this.....
    Jeff
     
    Jeff Mishler, Jun 30, 2004
    #10
  11. David Kozina

    David Kozina Guest

    Jeff,
    Thanks for the comments.
    This leads to 2 more questions...

    First, any thoughts on how to call this AcadX method correctly?
    I'm sure it's cake, but my brain goes flatline whenever other interfaces get
    involved.
    (Gads, I'm hopeless - sorry)

    Given:
    DBX_obj - DBX Document Object
    Block_obj - Block Ref Object in DBX_obj
    AttTag_obj - Attribute Tag Object in Block_obj
    *AcadX* - AcadX Object -> obtained from:

    (vl-load-com)
    (vlax-invoke-method
    (vlax-get-acad-object)
    'GetInterfaceObject
    "AcadX.Application"
    )


    I'm ASSuming it might be something like...
    (vlax-invoke-method *AcadX* 'UpdateTextAlignment AttTag_obj)

    Is that it?
    Cigar?
    Close?
    NearBroadSideOfBarn?
    NearPlanetEarth?


    Secondly... (for Tony)
    Is there going to be (or already) an updated AcadX available?
    (I understand the current one is set to expire mañana?)

    Best regards,
    David Kozina


     
    David Kozina, Jun 30, 2004
    #11
  12. David Kozina

    Jeff Mishler Guest

    Hmmm, 2 questions....8 question marks(?) ....... ;-)
    I haven't tried to use AcadX in lisp, and I've actaully only tried it in VBA
    a few times, so I can't answer this....sorry.

    Jeff
     
    Jeff Mishler, Jun 30, 2004
    #12
  13. David Kozina

    David Kozina Guest

    Jeff,
    When was Tony's message posted regarding this? - or what thread?


     
    David Kozina, Jun 30, 2004
    #13
  14. David Kozina

    Jeff Mishler Guest

    David,
    Tony's post was in reply to this post:

    From: "clarence_rollins" <>
    Newsgroups: autodesk.autocad.customization.vba
    Subject: ObjectDBX: Attribute's alignment point changes when its textstring
    value is modified
    Message-ID: <>
    Date: Sun, 16 Feb 2003 20:17:25 -0800

    Hmmm, I just noticed a R slipped into Tony's last name......sorry Tony.

    Jeff

     
    Jeff Mishler, Jun 30, 2004
    #14
  15. David Kozina

    David Kozina Guest

    Thanks Jeff...

    Well,

    (vlax-invoke-method *AcadX* 'UpdateTextAlignment AttTag_obj)

    doesn't work using the 2004/5 AcadX Beta, either because it just isn't
    available or, more likely, because I'm just not calling it right.

    I can't seem to find an AcadXUtility Object property either, so I don't know
    what to think.
    Stumbling around in the dark, as usual.


     
    David Kozina, Jun 30, 2004
    #15
  16. AcadXUtility is a class not a property, and you
    have to create an instance of it to use it:

    (setq Util (vla-getInterfaceObject *acad* "AcadX.Utility")




    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning


     
    Tony Tanzillo, Jul 1, 2004
    #16
  17. David - Yes, there is an update available, but it isn't free.



    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning


     
    Tony Tanzillo, Jul 1, 2004
    #17
  18. David Kozina

    David Kozina Guest

    YESSSS! Thanks, Tony!

    ObjectDBX attribute tag text alignment via AcadX works!

    Best regards,
    David Kozina


     
    David Kozina, Jul 14, 2004
    #18
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.