Author Topic: Xrecord Problem  (Read 1358 times)

0 Members and 1 Guest are viewing this topic.

mgreven

  • Guest
Xrecord Problem
« on: February 22, 2012, 11:02:54 AM »
Hello,

I have a wierd Xrecord problem with the following code.
When i run the following routine (Xrecord-Add "Mydict" "Mydata" '("1" "0" "0" "20;50;80" "50" "N1200" "2480;2500" "2480"))
Then de xrecord with the data is added to the drawing.

But when i run the following routine (Xrecord-Add "Mydict" "Mydata" '("1" "0" "0" "20;50;80" "50" "N1200" "2480;2500" "2480" "None" "None" "None"
"None" "None"))
I get a error message "Automation Error. Description was not provided."

What is wrong here?


(defun Xrecord-Add (dict name data / acadapp doc dicts xrec #typ #dat)
  (setq   acadapp  (vlax-get-acad-object)
   doc   (vla-get-ActiveDocument acadapp)
   dicts (vla-get-Dictionaries doc)
   dict  (vlax-invoke-method dicts "Add" dict)
   xrec  (vla-AddXrecord dict name)
  )
  (if (not (listp data))
    (setq data (list data))
  ) ; ensure list!  
  (vla-setXrecordData xrec (List->VariantArray (List->IntList data) 'vlax-vbInteger)
    (List->VariantArray data 'vlax-vbVariant)
  )
  (vla-getXrecordData xrec '#typ '#dat)
  (setq   #typ (vlax-Safearray->list #typ)
        #dat (vlax-Safearray->list #dat)
  )
  (mapcar 'vlax-variant-value #dat)
)

(defun List->VariantArray (lst datatype / arraySpace sArray)
  (setq   arraySpace (vlax-make-safearray (eval datatype) (cons 0 (1- (length lst)))))
  (setq sArray (vlax-Safearray-fill arraySpace lst))
  (vlax-make-variant sArray)
)
 

(defun List->IntList (lst / n)
  (setq n 0)
  (mapcar (function (lambda (x) (setq n (1+ n)))) lst)
)



Faster

  • Guest
Re: Xrecord Problem
« Reply #1 on: February 23, 2012, 07:26:01 AM »
XRecordDataType is wrong!
Help in AutoCAD:
Unlike XData, XRecords work with the standard AutoCAD group codes, which are all below 1000 in value. All the standard AutoCAD group codes are supported. This means that, in addition to all the normally used data types, an XRecord is capable of storing object IDs, which allows XRecords to own other objects including other XRecords.