Author Topic: Is there a way to store hidden information in a dwg file?  (Read 2967 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Is there a way to store hidden information in a dwg file?
« on: October 03, 2018, 04:01:38 PM »
I would like to store information in a dwg file that isn't found in dwgproperties or dependent on an existing entity within the dwg file (ie) xdata.

From what I understand, xdata must be attached to an entity
dwgproperties is already being used for other purposes so I can't utilize it.

What I'm trying to do is, create a list of tasks as a checkbox in dcl for a dwg file. A lisp script will read the information stored in the cad file and generate a list of checkboxes.

I hope that clarifies my question.


dubb

  • Swamp Rat
  • Posts: 1105
Re: Is there a way to store hidden information in a dwg file?
« Reply #2 on: October 03, 2018, 04:30:42 PM »
Xdata on layer 0 ?

I would still have to associate the xdata with an actual entity that exists in the drawing wouldn't I?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Is there a way to store hidden information in a dwg file?
« Reply #3 on: October 03, 2018, 04:32:17 PM »
Xdata on layer 0 ?

I would still have to associate the xdata with an actual entity that exists in the drawing wouldn't I?
All you have to do is register the application name you want to use and write away.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Is there a way to store hidden information in a dwg file?
« Reply #4 on: October 03, 2018, 04:36:00 PM »
Time ago I wrote myself one, and I was storirng inside xrecords (which are inside of dictionaries).
And these are the subfoos I'm using:

Code - Auto/Visual Lisp: [Select]
  1. ; (IncludeDataIntoMainDic "MyXrec" nil)
  2. ; (IncludeDataIntoMainDic "MyXrec" '("Custom" 2 "data"))
  3. ; xRecName - xrecord name
  4. ; dataL - basically any type of data (usually its a list) if nil, then the xrecord will be deleted.
  5. ; http://www.theswamp.org/index.php?topic=5003.0
  6. (defun IncludeDataIntoMainDic ( xRecName dataL / maindic xrec )
  7.   (cond
  8.     ( (not (eq 'STR (type xRecName))) (prompt "\nxRecName is not STR type.") )
  9.     ( (vl-some (function (lambda (x) (wcmatch (strcase xRecName) x))) '("ACAD*" "AEC*" "Ac*")) ; Being paranoid
  10.       (prompt "\nInvalid xRecord name.")
  11.     )
  12.     (t
  13.       (setq maindic (namedobjdict))
  14.       (if (setq xrec (dictsearch maindic xRecName)) (entdel (cdr (assoc -1 xrec))))
  15.       (if dataL (dictadd maindic xRecName (entmakex (append '((0 . "XRECORD") (100 . "AcDbXrecord")) (list (cons 1 (vl-prin1-to-string dataL)))))))
  16.     ); t
  17.   ); cond
  18. ); defun IncludeDataIntoMainDic
  19.  
  20. ; (GetDataFromMainDic "MyXrec")
  21. ; http://www.theswamp.org/index.php?topic=5003.0
  22. (defun GetDataFromMainDic ( xRecName / tmp r )
  23.   (and
  24.     (setq tmp (dictsearch (namedobjdict) xRecName))
  25.     (setq tmp (cdr (assoc 1 tmp)))
  26.     (setq r (read tmp))
  27.   ); and
  28.   r
  29. ); defun GetDataFromMainDic

And this is the GetStringList - with DCL.


(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

dubb

  • Swamp Rat
  • Posts: 1105
Re: Is there a way to store hidden information in a dwg file?
« Reply #5 on: October 03, 2018, 05:10:18 PM »
Interesting. I'll take a look at this.
Time ago I wrote myself one, and I was storirng inside xrecords (which are inside of dictionaries).
And these are the subfoos I'm using:

Code - Auto/Visual Lisp: [Select]
  1. ; (IncludeDataIntoMainDic "MyXrec" nil)
  2. ; (IncludeDataIntoMainDic "MyXrec" '("Custom" 2 "data"))
  3. ; xRecName - xrecord name
  4. ; dataL - basically any type of data (usually its a list) if nil, then the xrecord will be deleted.
  5. ; http://www.theswamp.org/index.php?topic=5003.0
  6. (defun IncludeDataIntoMainDic ( xRecName dataL / maindic xrec )
  7.   (cond
  8.     ( (not (eq 'STR (type xRecName))) (prompt "\nxRecName is not STR type.") )
  9.     ( (vl-some (function (lambda (x) (wcmatch (strcase xRecName) x))) '("ACAD*" "AEC*" "Ac*")) ; Being paranoid
  10.       (prompt "\nInvalid xRecord name.")
  11.     )
  12.     (t
  13.       (setq maindic (namedobjdict))
  14.       (if (setq xrec (dictsearch maindic xRecName)) (entdel (cdr (assoc -1 xrec))))
  15.       (if dataL (dictadd maindic xRecName (entmakex (append '((0 . "XRECORD") (100 . "AcDbXrecord")) (list (cons 1 (vl-prin1-to-string dataL)))))))
  16.     ); t
  17.   ); cond
  18. ); defun IncludeDataIntoMainDic
  19.  
  20. ; (GetDataFromMainDic "MyXrec")
  21. ; http://www.theswamp.org/index.php?topic=5003.0
  22. (defun GetDataFromMainDic ( xRecName / tmp r )
  23.   (and
  24.     (setq tmp (dictsearch (namedobjdict) xRecName))
  25.     (setq tmp (cdr (assoc 1 tmp)))
  26.     (setq r (read tmp))
  27.   ); and
  28.   r
  29. ); defun GetDataFromMainDic

And this is the GetStringList - with DCL.



Rod

  • Newt
  • Posts: 185
Re: Is there a way to store hidden information in a dwg file?
« Reply #6 on: October 03, 2018, 06:34:19 PM »
Nullptr wrote something a while ago that I think would allow you to embed any file inside a DWG xrecord.

I never used it but it could be useful to you.

http://www.theswamp.org/index.php?topic=26687.msg321539#msg321539
"All models are wrong, some models are useful" - George Box

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Is there a way to store hidden information in a dwg file?
« Reply #7 on: October 04, 2018, 10:04:51 AM »
Check the ActiveX/COM  documentation, specifically the GetXdata method.  You'll see that XDATA is a property of objects, not just entities (and yes - there *is* a difference between the two).
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Is there a way to store hidden information in a dwg file?
« Reply #8 on: October 04, 2018, 12:17:24 PM »
i personally prefer vlax-ldata-

GDF

  • Water Moccasin
  • Posts: 2081
Re: Is there a way to store hidden information in a dwg file?
« Reply #9 on: October 04, 2018, 01:43:27 PM »
Back in 2001 Cadalyst posted a lisp by John R. Fair III called message.lsp.

Tip1756a:  MESSAGE.LSP      Message Service            (c)2001, John R. Fair III;  $50 Bonus Winner
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64