Message 1 of 4
DbConnect CAO.GetLinks.count
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi folks,
I have a little problem with DbConnect...
My application (should) allows me to synchronize Block References (BR) with a Database Table (DT).
Synchronizing is not the problem.
The problem is I want to be able to Link the BR with DbConnect (create a Link programmatically), but it doesn't always work???
I have a sample DWG with 54 BR holding data to synchronize but without DbConnect Link Object (LO)
The amazing thing is that I test the app, sometimes it finds BR with LO and sometimes not!?!?
So, if I open the DWG, run the app, it will find that maybe BR nbr 20 or any other BR with 1 or even more LO.
If I close the DWG (without saving it), reopen it and restart the app then it will than other BR have LO's.
Every time I reopen the DWG and run the app, the result is different!?!?!?! Why???
The LinkTemplate just references the PK from the DataTable.
The app's part trying to link BR with LO runs as follow:
1. select all the Blocks and return them as array of ObjectIDs (PromptSelectionResult.Value.GetObjectIds())
2. loop each ObjectIDs
3. get the LO with CAO.GetLinks(LinkTemplate, ArrayOfOneObjectID, (int)CAO.LinkType.kEntityLinkType)
4. case LO.count == 0:
4.1. LinkTemplate.CreateLink(ArrayOfOneObjectID[0],CAO.KeyValues(TableFieldPKid, RecordID))
5. case LO.count == 1:
5.1. if LO.Item(0).KeyValues.Item(0).Value == RecordID then no need to change anything
5.2. if LO.Item(0).KeyValues.Item(0).Value != RecordID then change Value to RecordID
6. case LO.count > 1:
6.1. delete all LO which doesn't match RecordID
6.2. create new LO with RecordID
What's wrong with this?
Does the references to LOs change if create or modify one of them?
Why is LO.count different each time I reopen the DWG? This doesn't make sense!!!
The Form is divided in 3 sections:
TOP:
Select Block and Attribute to pair with LinkTemplate and FieldName
(checkboxes are not relevant for this problem)
LEFT:
Select which Attribute will be send to which Field in DataTable
RIGHT:
Select which Field from DataTable will change which Attribute Value