Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Updating custom table sources

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
568 Views, 3 Replies

Updating custom table sources

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

 

 

 

 

 

3 REPLIES 3
Message 2 of 4
xiaodong_liang
in reply to: Anonymous

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

 

 

Message 3 of 4
filat
in reply to: xiaodong_liang

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

Message 4 of 4
filat
in reply to: filat

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...

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report