TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mailmaverick on March 04, 2015, 12:00:22 PM
-
Dear All,
I want to store some data in AUTOCAD file. For example, as soon as an AUTOCAD file is opened on any computer, the computer name, date and time must be recorded automatically. When the same file is opened in another computer, the same information must be stored in addition to the earlier information.
Also, this information must be hidden from the users of the file but should be retrievable by me using LISP.
How to do so ?
-
You could use xdata (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=site:theswamp.org+xdata).
-
Do a search here on use of dictionaries, could be a very easy task to accomplish.
You will need to load a lisp function in your acad.lsp startup function, so to get it to work on computers outside your control will be tough to accomplish.
-
Some links:
----------- Ldata - xData -------------
http://www.theswamp.org/index.php?topic=30445.0 Quick XData Functions by Lee Mac
http://www.theswamp.org/index.php?topic=31804.0
http://www.theswamp.org/index.php?topic=5003.0 MP - dictionaries and xRecords
http://www.theswamp.org/index.php?topic=17203.msg207853#msg207853 Remove xData by MP
http://www.theswamp.org/index.php?topic=1283.0 Ldata vs xData
http://www.theswamp.org/index.php?topic=4395.0
http://www.theswamp.org/index.php?topic=8829.0
http://www.theswamp.org/index.php?topic=29381.0
http://www.theswamp.org/index.php?topic=23294.msg281024#msg281024 Ldata
http://www.theswamp.org/index.php?topic=29564.0
http://www.theswamp.org/index.php?topic=18490.0 Ldata example
http://www.afralisp.net/autolisp/tutorials/dictionaries-and-xrecords.php xRecord
http://cadtips.cadalyst.com/node/tiplisting?keywords=1756 Message Store Routine
Data Structures
http://www.theswamp.org/index.php?topic=37660.msg427038#msg427038 LeeMac
-
Here (http://bit.ly/127drDl)'s a concept Modification Logging Utility that I wrote as an example quite recently - it may give you some ideas.
Lee
-
Here (http://bit.ly/127drDl)'s a concept Modification Logging Utility that I wrote as an example quite recently - it may give you some ideas.
Lee
Excellent Lee !!! This is quite similar to what I wanted. Once again, Lee to the rescue.
I have seen that you have used Group Code -3. How come we can use a negative Group Code ?
Also, apart from -3, what other Group Codes can we assign to an entity which do not interfere with the AUTOCAD's predefined group codes ?
Also, you have assigned the data to an entity. How can we assign the data to a drawing file (not an entity).
-
Here's another .. you can choose what you'd like the data written to. My example writes to layer 0.
(defun _xdatalogger
(ename appname
/ data el
) )
"_"
"_"
)
)
)
)
)
)
)
)
)
(defun _readxdatalogger
(ename appname
) )
)
;; Log to layer 0
(_xdatalogger
(tblobjname "layer" "0") "MyDataLogger") ;; Read data
(_readxdatalogger
(tblobjname "layer" "0") "MyDataLogger")
-
Dear RONJONP, I am confused by your LISP.
Please explain how can we write data to a layer when a layer is not an entity like a circle, polyline etc.
-
Some links:
----------- Ldata - xData -------------
http://www.theswamp.org/index.php?topic=30445.0 Quick XData Functions by Lee Mac
http://www.theswamp.org/index.php?topic=31804.0
http://www.theswamp.org/index.php?topic=5003.0 MP - dictionaries and xRecords
http://www.theswamp.org/index.php?topic=17203.msg207853#msg207853 Remove xData by MP
http://www.theswamp.org/index.php?topic=1283.0 Ldata vs xData
http://www.theswamp.org/index.php?topic=4395.0
http://www.theswamp.org/index.php?topic=8829.0
http://www.theswamp.org/index.php?topic=29381.0
http://www.theswamp.org/index.php?topic=23294.msg281024#msg281024 Ldata
http://www.theswamp.org/index.php?topic=29564.0
http://www.theswamp.org/index.php?topic=18490.0 Ldata example
http://www.afralisp.net/autolisp/tutorials/dictionaries-and-xrecords.php xRecord
http://cadtips.cadalyst.com/node/tiplisting?keywords=1756 Message Store Routine
Data Structures
http://www.theswamp.org/index.php?topic=37660.msg427038#msg427038 LeeMac
I appreciate the comprehensive links list dear CAB.
-
Dear RONJONP, I am confused by your LISP.
Please explain how can we write data to a layer when a layer is not an entity like a circle, polyline etc.
Also, you have assigned the data to an entity. How can we assign the data to a drawing file (not an entity).
I thought you wanted to write the data to the "drawing" .. figured layer 0 is part of every drawing so I used it as an example. It does not have to be layer 0 that you write to. The function gives you flexibility to write to whatever makes you happy. :)
-
Here (http://bit.ly/127drDl)'s a concept Modification Logging Utility that I wrote as an example quite recently - it may give you some ideas.
Lee
Excellent Lee !!! This is quite similar to what I wanted. Once again, Lee to the rescue.
You're most welcome :-)
I have seen that you have used Group Code -3. How come we can use a negative Group Code ?
Also, apart from -3, what other Group Codes can we assign to an entity which do not interfere with the AUTOCAD's predefined group codes ?
All Extended Entity Data (xData) is stored under DXF group -3; I would recommend that you first read up on xData, perhaps starting here (http://www.afralisp.net/autolisp/tutorials/extended-entity-data-part-1.php).
Also, you have assigned the data to an entity. How can we assign the data to a drawing file (not an entity).
For this I would personally use a dictionary defined under the Named Object Dictionary (namedobjdict)
-
.....
For this I would personally use a dictionary defined under the Named Object Dictionary (namedobjdict)
I was thinking that too but after a quick test, the data gets lost if the drawing is wblocked. :|
-
Not if you make it hard owned. Search the swamp for same. :)
-
All Extended Entity Data (xData) is stored under DXF group -3; I would recommend that you first read up on xData, perhaps starting here (http://www.afralisp.net/autolisp/tutorials/extended-entity-data-part-1.php).
For this I would personally use a dictionary defined under the Named Object Dictionary (namedobjdict)
Thanks to Lee for all his inputs.
I thought you wanted to write the data to the "drawing" .. figured layer 0 is part of every drawing so I used it as an example. It does not have to be layer 0 that you write to. The function gives you flexibility to write to whatever makes you happy. :)
Dear Ron, I agree that I want to write the data to a drawing and not an entity. But i did not know that you can write data to a layer also. In that case, can we write such datas to Dimension Styles, Text Styles etc ?
Is there any comprehensive list of AUTOCAD objects which support data writing ? If any link is available, please let me know.
-
...
Is there any comprehensive list of AUTOCAD objects which support data writing ? If any link is available, please let me know.
There is a list of supported objects in the HELP (http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-EF0393EC-8446-4989-8C72-F3AE49D81176) file :)
object
Type: All drawing objects, AttributeReference, Block, Dictionary, Dimension, DimStyle, Group, Layer, Layout, Linetype, Material, MLeaderStyle, PlotConfiguration, RegisteredApplication, TableStyle, TextStyle, UCS, View, Viewport, XRecord
The object this method applies to.
-
Not if you make it hard owned. Search the swamp for same. :)
Will do Michael .. thanks :)
-
You can add data to anything that derives from AcDbObject object. So any object that can be saved in a autocad file or another way of putting it is a whole butt-load
Now most of these objects have many objects derived from them like a layer that derives from symbolTableRecord
AcDbAssocAction
AcDbAssocActionBody
AcDbAssocActionParam
AcDbAssocDependency
AcDbAssocDependencyBody
AcDbAssocManager
AcDbBackground
AcDbBreakData
AcDbBreakPointRef
AcDbColor
AcDbDataLink
AcDbDataTable
AcDbDictionary
AcDbDimAssoc
AcDbEntity
AcDbEvalExpr
AcDbEvalGraph
AcDbField
AcDbFilter
AcDbGeoData
AcDbGroup
AcDbIndex
AcDbLinkedData
AcDbLongTransaction
AcDbMaterial
AcDbMLeaderStyle
AcDbMlineStyle
AcDbModelDocViewStyle
AcDbMotionPath
AcDbNamedPath
AcDbPlaceHolder
AcDbPlotSettings
AcDbPointCloudColorMap
AcDbPointCloudDefEx
AcDbPointCloudDefReactorEx
AcDbProxyObject
AcDbRasterImageDef
AcDbRasterImageDefReactor
AcDbRasterVariables
AcDbRenderEnvironment
AcDbRenderGlobal
AcDbRenderSettings
AcDbSectionManager
AcDbSectionSettings
AcDbSortentsTable
AcDbSun
AcDbSymbolTable
AcDbSymbolTableRecord
AcDbAbstractViewTableRecord
AcDbBlockTableRecord
AcDbDimStyleTableRecord
AcDbLayerTableRecord
AcDbLinetypeTableRecord
AcDbRegAppTableRecord
AcDbTextStyleTableRecord
AcDbUCSTableRecord
AcDbTableStyle
AcDbUnderlayDefinition
AcDbVisualStyle
AcDbXrecord