Correct or missing?

Discussion in 'AutoCAD' started by Rudy Tovar, Jan 14, 2004.

  1. Rudy Tovar

    Rudy Tovar Guest

    Set existing dimstyle "ARCH1" current.

    ; Property values:
    ; Application (RO) = #<VLA-OBJECT 00b287f0>
    ; Name = "ARCH2"
    ; Methods supported:
    ; Delete ()
    ; GetXData (3)
    ; SetXData (2)


    (setq a (vla-get-activedimstyle (vla-get-ActiveDocument
    (vlax-get-Acad-Object))))
    (vla-put-name a "arch1");<errors out..

    Or am I barking up the wrong tree. I'm just brain dead.
     
    Rudy Tovar, Jan 14, 2004
    #1
  2. From the ActiveX docs:

    Name

    String;
    Read-write for the following objects: Block, BlockRef, Dictionary, DimStyle,
    Group, Layer, Layout, Linetype, PlotConfiguration, PopupMenu, Raster,
    RegisteredApplication, Shape, Toolbar, ToolbarItem, UCS, View, Viewport,
    XRecord.

    Read-only for the following objects: Application, Document, MenuGroup,
    ModelSpace, PaperSpace, SelectionSet, TextStyle.


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | Set existing dimstyle "ARCH1" current.
    |
    | ; Property values:
    | ; Application (RO) = #<VLA-OBJECT 00b287f0>
    | ; Name = "ARCH2"
    | ; Methods supported:
    | ; Delete ()
    | ; GetXData (3)
    | ; SetXData (2)
    |
    |
    | (setq a (vla-get-activedimstyle (vla-get-ActiveDocument
    | (vlax-get-Acad-Object))))
    | (vla-put-name a "arch1");<errors out..
    |
    | Or am I barking up the wrong tree. I'm just brain dead.
    |
    |
     
    R. Robert Bell, Jan 14, 2004
    #2
  3. Rudy Tovar

    BillZ Guest

    It looks like you are trying to put an object where it's expecting a name.
    (setq a (vla-get-name (vla-get-activedimstyle (vla-get-ActiveDocument
    (vlax-get-Acad-Object)))))
    Would make a the name of the active dimstyle.
    Or am I missing something?

    Bill
     
    BillZ, Jan 14, 2004
    #3
  4. Rudy Tovar

    Rudy Tovar Guest

    Or perhaps it only works the first time when it's created?
     
    Rudy Tovar, Jan 14, 2004
    #4
  5. Rudy Tovar

    Rudy Tovar Guest

    I get the following error also for-
    *** ERROR: argument type mismatch: "arch1"
    (vla-put-activedimstyle (vla-get-ActiveDocument (vlax-get-Acad-Object))
    "ARCH1")
     
    Rudy Tovar, Jan 14, 2004
    #5
  6. Rudy,

    Do you want to rename ARCH2 -> ARCH1

    (setq a (vla-get-activedimstyle
    (vla-get-ActiveDocument
    (vlax-get-Acad-Object))))

    ;; rename dimension style
    (vla-put-name a "ARCH1")

    ;; update the dimension style list
    (vla-update (vlax-get-acad-object))

    Then it won't be necessary to make it current.

    hth.
     
    Luis Esquivel, Jan 14, 2004
    #6
  7. Rudy Tovar

    Jeff Mishler Guest

    if you are trying to set the current dimstyle to "arch1":

    (setq a (vla-get-activedimstyle (vla-get-ActiveDocument

    (vlax-get-Acad-Object))))
    (vla-put-name a "arch1");<--only changes the name of the dimstyle

    (setq dimstyl (vla-item (vla-get-dimstyles doc) "arch1"));get the arch1
    dimstyle

    (vla-put-activedimstyle doc dimstyl);set current style to arch1

    HTH,
    Jeff
     
    Jeff Mishler, Jan 14, 2004
    #7
  8. Rudy Tovar

    Rudy Tovar Guest

    I have existing dimstyles and be able to toggle from one to the other just
    like setvar.

    I tried setvariable, but that didn't work.

    Supposedly you can set another existing dimstyle current using activex.
     
    Rudy Tovar, Jan 14, 2004
    #8
  9. Rudy Tovar

    Rudy Tovar Guest

    I tried that too...

    I'll try it again...thanks.........................

    It worked! Thanks for rattling my brain.
     
    Rudy Tovar, Jan 14, 2004
    #9
  10. Rudy Tovar

    Rudy Tovar Guest

    So you have to return the existing ENTIRE object, and set it via
    vla-put-activedimstyle. That's what I was looking at in my face and my brain
    kept telling me, but I didn't understand because I was so use to setting
    only face values, as strings and arrays.

    Thanks for draining my brain....
     
    Rudy Tovar, Jan 14, 2004
    #10
  11. Rudy,

    This is what I use to set a dimstyle current:

    (defun put-activedimstyle (dimname / dimstyle thisdwg)
    (if (not (vl-catch-all-error-p
    (setq dimstyle (vl-catch-all-apply
    'vla-item
    (list (vla-get-dimstyles
    (setq thisdwg
    (vla-get-activedocument
    (vlax-get-acad-object))))
    dimname)))))
    (vla-put-activedimstyle thisdwg dimstyle)))

    hth
     
    Luis Esquivel, Jan 14, 2004
    #11
  12. Rudy Tovar

    Rudy Tovar Guest

    I'll have to review this once more.

    It's creating a copy of the existing style and saving it with the same name
    as the existing name I'd like to make current.

    I'll give Luis a try.
     
    Rudy Tovar, Jan 14, 2004
    #12
  13. Rudy Tovar

    Jeff Mishler Guest

    Rudy,
    Luis' and my are essentially the same. If you are using everything I
    posted, that is NOT what you want to be doing. I was merely showing you
    what your original code was doing, then showing HOW you should be doing
    it.....

    Jeff
     
    Jeff Mishler, Jan 14, 2004
    #13
  14. That's true ... is the same... as Jeff coding...

    Asi es, solo que en mi caso la funcion revisa que exista el nombre del
    estilo primero antes de hacerlo vigente.

    Suerte,
    Luis.
     
    Luis Esquivel, Jan 14, 2004
    #14
  15. Rudy Tovar

    Rudy Tovar Guest

    Sinerio - Existing dimstyles - toggle from one to another, via toolbar.

    If not existing dimstyle, make dimstyle, then set dimstyle current.

    That's it, but using your method is causing autocad to create another +arch1
    and save with that name current settings.

    I'll look at it a bit more this afternoon. Perhaps I'm doing something out
    of order.

    Also, I'm making it work in different versions, R14-2004.
     
    Rudy Tovar, Jan 14, 2004
    #15
  16. Sorry, my eyes only saw "style". I read your post too fast.
     
    R. Robert Bell, Jan 15, 2004
    #16
  17. Rudy Tovar

    Doug Broad Guest

    Rudy,
    This may already have been answered.

    The reason for the error is that you can't rename the
    active dimension style to the name of another dimstyle
    in the current drawing. Each dimstyle must have a unique
    identifier. If you are trying to switch dimstyles, then

    (setq doc (vla-get-activedocument(vlax-get-acad-object))
    nds (vla-item (vla-get-dimstyles doc) "arch1")) ;<--any valid dimstyle name
    (vla-put-activedimstyle doc nds)
     
    Doug Broad, Jan 15, 2004
    #17
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.