xdata 1003

Discussion in 'AutoCAD' started by alex, Mar 28, 2005.

  1. alex

    alex Guest

    I tried to use entmod to fill this field with different layer name and got
    an error.
    is it requied to look at it as and object and use setxdata?

    thanks, Alex
     
    alex, Mar 28, 2005
    #1
  2. alex

    Jürg Menzi Guest

    Hi Alex

    Does this Layer name exist? The Xdata fields 1003/1005 require a valid
    LayerName/Handle...

    Cheers
     
    Jürg Menzi, Mar 29, 2005
    #2
  3. alex

    alex Guest

    We went to a new layering system designed to accomodate the many at the
    expense or productivity in my opinion.
    The new system has big long fluent descriptions so that just about anyone
    looking at it will know what it is.
    I was used to a 5 chr field based system that requied learning the system
    but once you did that layer manipulation was fast and powerful.
    for example, via some lisp routines i made up i could type: zn 2u and any
    utilites in my dwg would get turned on. zo 1eu would turn off all existing
    utilites. etc. etc.
    very fast but requires learning a system and not all players on the team
    will ever be willing or able to learn a system like that.
    So i am thinking of storing my layer naming system in extended data and
    modify my routines to act off that field instead of 8 for layer.

    perhaps there is another approach also but i thought i would give this a
    try.

    Thanks, Alex
     
    alex, Mar 29, 2005
    #3
  4. alex

    Jürg Menzi Guest

    Hi Alex

    Welcome...¦-)

    As an alternative you can use a code 1000 (string) field to store the layer
    names.

    Cheers
     
    Jürg Menzi, Mar 29, 2005
    #4
  5. alex

    alex Guest

    thanks.
     
    alex, Mar 30, 2005
    #5
  6. alex

    alex Guest

    I can to store to the 1000 field either. the 1003 would probably work it is
    just that I can not figure out how to write to it. the entmod returns an
    error.
     
    alex, Mar 30, 2005
    #6
  7. alex

    Jürg Menzi Guest

    Hi Alex

    I use this functions to handle Xdata:
    Code:
    ;
    ; == Function MeGetXdata
    ; Reads Xdata from an entity.
    ; Copyright:
    ;   ©2004 MENZI ENGINEERING GmbH, Switzerland
    ; Arguments [Type]:
    ;   Obj = Object to read Xdata from [VLA-OBJECT]
    ;   App = AppID [STR]
    ; Return [Type]:
    ;   > List of Xdata '((F1 . D1)...(Fx . Dx)) [LIST]
    ;   > False if no Xdata found
    ; Notes:
    ;   - App argument "" gets all Xdata from an object
    ;
    (defun MeGetXdata (Obj App / DatArr FldArr)
    (vla-GetXData Obj App 'FldArr 'DatArr)
    (if (and FldArr DatArr)
    (mapcar
    '(lambda (f v) (cons f v))
    (vlax-safearray->list FldArr)
    (mapcar
    '(lambda (l)
    (if (= (logand (vlax-variant-type l) vlax-vbArray) vlax-vbArray)
    (vlax-safearray->list (vlax-variant-value l))
    (vlax-variant-value l)
    )
    ) (vlax-safearray->list DatArr)
    )
    )
    )
    )
    ;
    ; == Function MeSetXdata
    ; Writes Xdata into an entity.
    ; Copyright:
    ;   ©2004 MENZI ENGINEERING GmbH, Switzerland
    ; Arguments [Type]:
    ;   Obj = Object to write Xdata [VLA-OBJECT]
    ;   Lst = Xdata list '((F1 . D1)...(Fx . Dx)) [LIST]
    ; Return [Type]:
    ;   > True if succeed
    ;   > False if fail
    ; Notes:
    ;   - To delete Xdata, call the function with AppId only:
    ;     (MeSetXdata Obj '((1001 . "MyAppId")))
    ;
    (defun MeSetXdata (Obj Lst / FldArr DatArr)
    (setq FldArr (MeConvToXlist (mapcar 'car Lst) vlax-vbInteger)
    DatArr (MeConvToXlist (mapcar 'cdr Lst) vlax-vbVariant)
    )
    (not
    (vl-catch-all-error-p
    (vl-catch-all-apply 'vla-SetXData (list Obj FldArr DatArr))
    )
    )
    )
    ;
    ; == Function MeConvToXlist
    ; Converts a list to an array for XDatas.
    ; Copyright:
    ;   ©2004 MENZI ENGINEERING GmbH, Switzerland
    ; Arguments [Type]:
    ;   Dat = Data list [LIST]
    ;   Typ = Variable type [INT]
    ; Return [Type]:
    ;   > Data array [SAFEARRAY]
    ; Notes:
    ;   None
    ;
    (defun MeConvToXlist (Dat Typ)
    (vlax-make-variant
    (vlax-safearray-fill
    (vlax-make-safearray Typ (cons 0 (1- (length Dat))))
    (mapcar
    '(lambda (l)
    (if (= (type l) 'LIST)
    (vlax-safearray-fill
    (vlax-make-safearray vlax-vbDouble (cons 0 (1- (length l))))
    l
    )
    l
    )
    ) Dat
    )
    )
    )
    )
    Use:
    _$ (MeSetXdata (vlax-ename->vla-object (car (entsel))) '((1001 . "MyXdata")
    (1003 . "MyLayerName")))
    T
    _$ (MeGetXdata (vlax-ename->vla-object (car (entsel))) "MyXdata")
    ((1001 . "MyXdata") (1003 . "MyLayerName"))

    Cheers
     
    Jürg Menzi, Mar 30, 2005
    #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.