
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I'm really struggling with this. I know I can do this with .NET code (via the connectionString property), and I believe I can probably even compile .NET code on the fly from within VBA for this however, my specific project requirements incline one to believe that the user would like to avoid .NET code (& also C/C++ code).
The closest I've come to solving this issue can be partially seen by examining the following code that I have been progressively drawing up:
Dim linkName As String linkName = "test" Dim DataLinkDictionary As AcadDictionary Set DataLinkDictionary = AutoCAD.AcadApplication.ActiveDocument.Dictionaries.Item("ACAD_DATALINK") Dim DataLinkIterator As AcadObject For Each DataLinkIterator In DataLinkDictionary If (UCase(DataLinkDictionary.GetName(DataLinkIterator)) = UCase(linkName)) Then With AutoCAD.AcadApplication.ActiveDocument .SendCommand _ "(setq datalinkdefinition (entget (handent " & """" & DataLinkIterator.Handle & """" & ")))" _ & vbCrLf .SendCommand _ "(setq datalinkdefinition (subst " & _ "(cons 302 ""C:\\Users\\mark.j.fernandes\\OneDrive\\Documents\\employment\\21.6.19 AutoCAD project\\TestTableSpreadsheet.xlsx!Sheet2"") " & _ "(assoc 302 datalinkdefinition) datalinkdefinition ))" & vbCrLf ' NEED TO DO MORE THAN SIMPLY CHANGE THE ELEMENT WITH KEY 302--more complicated than that. .SendCommand _ "(entmod datalinkdefinition) " & vbCrLf ' .SendCommand "DATALINKUPDATE" & vbCrLf End With Exit For End If Next
So I'm able to modify the data definition for data link entities but the entity data-definition structure for data links appears to be quite unusual so I'm unsure exactly how to set the connection string.
The following lisp list that is for a data link entity (as an example) gives you an idea of the unusual structure (specifically notice how the path appears three times):
( (-1 . <Entity name: b6e2b56360>) (0 . "DATALINK") (5 . "216") (102 . "{ACAD_XDICTIONARY") (360 . <Entity name: b6e2b56420>) (102 . "}") (102 . "{ACAD_REACTORS") (330 . <Entity name: b6e2b56350>) (102 . "}") (330 . <Entity name: b6e2b56350>) (100 . "AcDbDataLink") (1 . "AcExcel") (300 . "") (301 . "Data Link\ntest\nC:\\Users\\mark.j.fernandes\\OneDrive\\Documents\\employment\\21.6.19 AutoCAD project\\TestTableSpreadsheet.xlsx\nLink details: Entire sheet: Sheet1") (302 . "C:\\Users\\mark.j.fernandes\\OneDrive\\Documents\\employment\\21.6.19 AutoCAD project\\TestTableSpreadsheet.xlsx!Sheet1") (90 . 2) (91 . 68943873) (92 . 1) (170 . 2019) (171 . 6) (172 . 23) (173 . 11) (174 . 37) (175 . 18) (176 . 0) (177 . 0) (93 . 0) (304 . "") (94 . 0) (360 . <Entity name: b6e2b56370>) (305 . "CUSTOMDATA") (1 . "DATAMAP_BEGIN") (90 . 3) (300 . "ACEXCEL_CONNECTION_STRING") (301 . "DATAMAP_VALUE") (93 . 2) (90 . 4) (1 . "C:\\Users\\mark.j.fernandes\\OneDrive\\Documents\\employment\\21.6.19 AutoCAD project\\TestTableSpreadsheet.xlsx!Sheet1") (94 . 0) (300 . "") (302 . "") (304 . "ACVALUE_END") (300 . "ACEXCEL_SOURCEDATE") (301 . "DATAMAP_VALUE") (93 . 2) (90 . 8) (92 . 16) (310 . "E3070600000017000C00200003000000") (94 . 0) (300 . "") (302 . "") (304 . "ACVALUE_END") (300 . "ACEXCEL_UPDATEOPTIONS") (301 . "DATAMAP_VALUE") (93 . 2) (90 . 1) (91 . 68943873) (94 . 0) (300 . "") (302 . "") (304 . "ACVALUE_END") (309 . "DATAMAP_END")
I can't get my head completely around this structure, and it appears it isn't fully documented by Autodesk. Does anyone know any different?
I've had a look at the CAO library (I believe that the suggestion in the post here, advises that this library [Connectivity Automation Object Library 1.0 type library] be used for my issue) but it doesn't seem to be applicable to data links; instead, it seems to possibly apply to label links. Has anyone successfully used the CAO library for this? I'm wondering whether the author of the just mentioned post meant a different library. Perhaps they meant the AcObjClassImp 1.0 type library; unfortunately, this other library doesn't appear to be documented by Autodesk at all.
I've looked at possibly using the NETLOAD command with the .NET API ObjectArx library/libraries but it doesn't appear that you can access .NET functionality in a straight-forward way by using this command; instead, it seems that when you make use of the NETLOAD command for this problem, that you should compile .NET code for what I'm trying to do (which is something I want to avoid if I can).
Am really struggling with this so would very much appreciate some help on this.
Thanks,
Mark
Solved! Go to Solution.