Message 1 of 3
Unable to add Attributesets using ApprenticeServer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I'm attempting to add an attributeset to a document using Apprentice, however, I am getting a System.Runtime.InteropServices.COMException when it comes to adding it. As below:
Code as follows:
Dim m_ApprenticeApp As ApprenticeServerComponent = New ApprenticeServerComponent()
Dim doc As ApprenticeServerDocument
Dim ffn As String = "C:\temp\Part1.ipt"
doc = m_ApprenticeApp.Open(ffn)
Dim NameOfNewPS As String = "MyNewSet"
Dim oNewPS As AttributeSet
If doc.AttributeManager.FindAttributeSets(NameOfNewPS).Count > 0 Then
' if the set exists aleady
oNewPS = doc.AttributeSets(NameOfNewPS)
Else
' add a new one
oNewPS = doc.AttributeSets.Add(NameOfNewPS)
End If
I have it set to compile using x64, and have reference to the autodesk.inventor.interop. I should note that I can add iProperties with no issues using this:
Dim m_ApprenticeApp As ApprenticeServerComponent = New ApprenticeServerComponent()
Dim doc As ApprenticeServerDocument
Dim ffn As String = "C:\temp\Part1.ipt"
doc = m_ApprenticeApp.Open(ffn)
Dim iPropSet As Inventor.PropertySet = doc.PropertySets.Item("Inventor User Defined Properties")
Dim prop As Inventor.Property = Nothing
Dim PropName As String = "Test"
Dim found As Boolean = False
For Each prop In iPropSet
Debug.WriteLine(prop.Name)
If prop.Name = PropName Then
found = True
Exit For
End If
Next
If Not found Then
prop = iPropSet.Add("1234", "Test")
End If
doc.PropertySets.FlushToFile()
This link confirms attributes are read/write and gives an example. I can't seem to figure out where it's going wrong at my end. Can anyone shed any light?
Regards