Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: meGVGMF

Hi @meGVGMF.  Using ThisDoc.Document will usually return the same document object as ThisDoc.FactoryDocument, when you have that model document open directly, and 'active' on your screen, but just as @CattabianiI pointed out, that may not be the case in other odd situations, where you may not be directly editing the model as the 'active' document.  He also pointed out one of the main tools for checking if the document you have is a 'member' or 'factory', which I also pointed out within the 'Link' at the end of my earlier responce.

Here is an example you can look at:

Dim oDoc As Document = ThisDoc.Document 'or ThisDoc.FactoryDocument
Dim oMSTable As ModelStateTable = Nothing
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
	Dim oADoc As AssemblyDocument = oDoc
	If oADoc.ComponentDefinition.IsModelStateMember Then oADoc = oADoc.ComponentDefinition.FactoryDocument
	oMSTable = oADoc.ComponentDefinition.ModelStates.ModelStateTable
ElseIf oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
	Dim oPDoc As PartDocument = oDoc
	If oPDoc.ComponentDefinition.IsModelStateMember Then oPDoc = oPDoc.ComponentDefinition.FactoryDocument
	oMSTable = oPDoc.ComponentDefinition.ModelStates.ModelStateTable
Else
	Exit Sub 'wrong document type
End If
'now you should have obtained the ModelStateTable from the 'Factory' document
Dim oMyCol As ModelStateTableColumn = Nothing
For Each oCol As ModelStateTableColumn In oMSTable.TableColumns
	If oCol.ReferencedDataType = iComponentColumnTypeEnum.kFilePropertyColumn And _
		oCol.DisplayHeading = "MyCustomPropertyName" Then
		oMyCol = oCol : Exit For
	End If
Next
oMSTable.TableRows.Item("ModelStateName").Item(oMyCol).Value = ""
'oMSTable.TableRows.Item("ModelStateName").Item("ColumnHeading").Value = ""

Wesley Crihfield

EESignature

(Not an Autodesk Employee)