0 Members and 1 Guest are viewing this topic.
Hello Can anyone tell me if it is possible to work with vla-setXData during or after vla-setXData.Thanksvelasquez
Quote from: velasquez on February 21, 2014, 06:42:44 PMHello Can anyone tell me if it is possible to work with vla-setXData during or after vla-setXData.Thanksvelasquezdid you mean to say .... is possible to work with vla-setXData during or after vla-AddBlock. ?
Code - Auto/Visual Lisp: [Select](setq blockObj (vla-Add blocks insertionPnt "New_Block")) (vla-SetXData blockObj DataType Data)
Show us your code in full.
;;;I am working with the functions that are in the post below;;;http://www.theswamp.org/index.php?topic=29366.msg349174#msg349174;;;I THANK THE PEOPLE WHO HAVE POSTED.;;;Make Xdata(defun JoyPutXdata (JoyObj JoyApp JoyData / JoyXtype JoyXval) (setq JoyXtype (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbInteger '(0 . 1) ) ;_ fim de vlax-make-safearray '(1001 1000) ) ;_ fim de vlax-safearray-fill ) ;_ fim de vlax-make-variant ) ;_ fim de setq (setq JoyXval (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbVariant '(0 . 1) ) ;_ fim de vlax-make-safearray (list JoyApp JoyData) ) ;_ fim de vlax-safearray-fill ) ;_ fim de vlax-make-variant ) ;_ fim de setq (vla-setXData JoyObj JoyXtype JoyXval)) ;_ fim de defun;;;;;;MakeBlock;;; (rcmd-makeBlock pt "TEST1" ss T)(defun rcmd-makeBlock (pt name ss flag / JoyDock ssArray vla_block) (setq JoyDoc (vla-get-activedocument (vlax-get-acad-object))) (vla-copyObjects JoyDoc (setq ssArray (rcmd-selectionSet->array ss)) (setq vla_block (vla-add (vla-get-blocks (rcmd-thisDwg)) (vlax-3d-point pt) name ) ;_ fim de vla-add ) ;_ fim de setq ) ;_ fim de vla-copyObjects ;; delete objects (if (and flag ssArray (= (type ssArray) 'safeArray) ;; is the safeArray made of vlax-object's (= (vlax-safeArray-type ssArray) 9) ) ;_ fim de and (mapcar 'vla-delete (safeArray-value ssArray)) ) ;_ fim de if ;;;Test Xdata (vla-setXData vla_block JoyXtype JoyXval)) ;_ fim de defun;;;
Hello Kerry You understood my problem well. "add XData to the blockDefinition" Thanks
(defun test ( / def doc ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-add (vla-get-registeredapplications doc) "my-app") (setq def (vla-add (vla-get-blocks doc) (vlax-3D-point 0 0) "my-block")) (vla-setxdata def (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbinteger '(0 . 1)) '(1001 1000))) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbvariant '(0 . 1)) '("my-app" "test"))) ))
(gc:SetXdata obj '((1001 . "my_app") (1000 . "test")))
(gc:GetXdata obj "my_app")
...But xdata added to a block definition won't be copied in the block references (inserts).
; =========================================================================================== ;; Czyta dane dodatkowe XDATA / Reads additional data XDATA ;; Ename [ENAME] - nazwa entycji / entity name ;; App [STR/nil] - nil = dla wszystkich aplikacji / for all applications ;; STR = dla aplikacji App / for App application ;; ------------------------------------------------------------------------------------------- ;; (cd:XDT_GetXData (car (entsel)) "CADPL") ;; =========================================================================================== ;(defun cd:XDT_GetXData (Ename App) (if App (cadr (assoc -3 (entget Ename (list App)))) (cdr (assoc -3 (entget Ename (list "*")))) )); =========================================================================================== ;; Dodaje dane dodatkowe XDATA / Adds additional data XDATA ;; Ename [ENAME] - nazwa entycji / entity name ;; App [STR] - nazwa aplikacji / application name ;; Data [LIST] - lista danych / data list ;; ------------------------------------------------------------------------------------------- ;; (cd:XDT_PutXData (car (entsel)) "CADPL" '((1000 . "X") (1070 . 5))) ;; =========================================================================================== ;(defun cd:XDT_PutXData (Ename App Data) (regapp App) (entmod (append (entget Ename) (list (list -3 (cons App Data))) ) )); =========================================================================================== ;; Usuwa dane dodatkowe XDATA / Removes additional data XDATA ;; Ename [ENAME] - nazwa entycji / entity name ;; App [STR] - nil = z wszystkich aplikacji / from all applications ;; STR = z aplikacji App / from App application ;; ------------------------------------------------------------------------------------------- ;; (cd:XDT_RemoveXData (car (entsel)) "CADPL") ;; =========================================================================================== ;(defun cd:XDT_RemoveXData (Ename App) (if (and App (cd:XDT_GetXData Ename App) ) (entmod (list (cons -1 Ename) (list -3 (list App)))) (foreach % (mapcar (quote car) (cd:XDT_GetXData Ename nil) ) (entmod (list (cons -1 Ename) (list -3 (list %)))) ) ))
Some suggestions
Quote from: Lee Mac on February 22, 2014, 05:42:58 PMSome suggestionsthanks Leereally like GetXdata need to closer review other two.
any reason why you don't want recall GetXdata in RemoveXData ?
hi,You can add xdata (as extension dictionary) to any AutoCAD object (graphical entities, symbol table records (layers, block definitions, ...), dictionaries).But xdata added to a block definition won't be copied in the block references (inserts).
Quote from: gile on February 22, 2014, 04:39:34 PMhi,You can add xdata (as extension dictionary) to any AutoCAD object (graphical entities, symbol table records (layers, block definitions, ...), dictionaries).But xdata added to a block definition won't be copied in the block references (inserts).Thanks gile : That was the conclusion I came to ... something I wasn't explicitly aware of.@ velasquezThe code you posted seems to be fine for making the block definition and adding the xdata to the definition.You may be able to read the xdata from the definition and add it to the insert ( reference ).Unfortunately this will mean that ONLY the inserts that use your routine will be fully compliant with your requirements.As usually happens here, the responses posted offer alternatives to the question you asked. ( and to ones you didn't ask )
?Code: [Select](defun test ( / def doc ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-add (vla-get-registeredapplications doc) "my-app") (setq def (vla-add (vla-get-blocks doc) (vlax-3D-point 0 0) "my-block")) (vla-setxdata def (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbinteger '(0 . 1)) '(1001 1000))) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbvariant '(0 . 1)) '("my-app" "test"))) ))