Updating custom table sources

Updating custom table sources

Anonymous
Not applicable
725 Views
3 Replies
Message 1 of 4

Updating custom table sources

Anonymous
Not applicable

I need help updating the source of a custom table in a drawing. I wrote a design copy rule that takes a template "module" and saves all the files off into the customer's project folder. This latest module has an orientation chart that details the location of key features and is displayed on the drawing. We're driving the chart using an external excel file. I can get the reference in the assembly to update with no problem by just telling the driving rule to look for an excel with matching project and assembly numbers in the same folder as the assembly.

 

However, when I try and update the reference in the drawing, I can get the "3rd Party" link to change, but it doesn't change the actual link in the table. Here's a pic of the tree and my part of the current code. How can I make it update the actual link?

 

Not updating.PNG

Try
Dim oSht As Sheet = oDwgDoc.Sheets.Item(1)

Dim oChart As CustomTable = oSht.CustomTables.Item(1)
 
MsgBox(oChart.Title)
Dim oChartDesc As FileDescriptor = oChart.ReferencedDocumentDescriptor
chartDocName = oDwgDoc.ReferencedDocumentDescriptors.Item(1).FullDocumentName
If chartDocName.Contains("OrientationChart") Then
	MsgBox("The dude contains")
End If 
orientChartName = Left(iProperties.Value("Custom", "OldName"), 3) & Parameter("projectNum") & Parameter("itemNum") & "OrientationChart.xlsx"
orientChartPath = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\"
oChartDesc.ReplaceReference(orientChartPath & orientChartName)
oChart.Update
'I've Also tried: oChart.AddLink(orientChartPath & orientChartName) but it always errors

 

 

 

 

 

0 Likes
726 Views
3 Replies
Replies (3)
Message 2 of 4

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

I gave a small test in 2014. It works well. The test video is at:

http://sdrv.ms/18TGdmo

 

I have not 2013 installed at this moment. But if you think I did not miss anything to reproduce your problem, I can try to find a 2013 to test.

 

The VBA code I used is as below:

 

Public Sub test()
   
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oCTable As CustomTable
    Set oCTable = oDoc.SelectSet(1)
    
    Call oCTable.ReferencedDocumentDescriptor.ReplaceReference("c:\temp\book22222222.xlsx")
    
End Sub

 

 

0 Likes
Message 3 of 4

filat
Advisor
Advisor

I can not replace the reference to the table. I watched in debug mode: for the ReferenceDocumentDescriptor reports an Unrecognized error. How can this problem be solved?


 


1.jpg

0 Likes
Message 4 of 4

filat
Advisor
Advisor

If I perform a replacement in a separate Sub, then the ReferenceDocumentDescriptors exists and the replacement is performed well.
But if this code is part of a large Sub, then the ReferenceDocumentDescriptors come with an unidentified error and you can not replace the reference.
How to find out why the error appears in:

 

Dim sSheet As Sheet
sSheet = oDoc.Sheets.Item(1)
Dim oCTable As CustomTable
oCTable = sSheet.CustomTables.Item(1)
Call oCTable.ReferencedDocumentDescriptor.ReplaceReference...

 

0 Likes