Hi
I try to copy "Revision Number" from drawing to reference part and got Microsoft Copilot to help me but not to the goal line :-). The code is like this:
' Kontrollera att det aktiva dokumentet är en ritning If ThisApplication.ActiveDocument.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then MessageBox.Show("Detta skript fungerar endast med ritningsdokument.", "Fel") Return End If ' Hämta ritningsrevisionen Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim revision As String revision = iProperties.Value("Project","Revision Number") ' Kontrollera att det finns en kopplad partfil If oDrawingDoc.ReferencedDocumentDescriptors.Count = 0 Then MessageBox.Show("Ingen kopplad partfil hittades.", "Fel") Return End If ' Hämta den första kopplade partfilen Dim oPartDescriptor As DocumentDescriptor oPartDescriptor = oDrawingDoc.ReferencedDocumentDescriptors.Item(1) ' Kontrollera om partfilen redan är öppen Dim oPartDoc As PartDocument If oPartDescriptor.ReferencedDocument Is Nothing Then ' Öppna partfilen om den inte redan är öppen oPartDoc = ThisApplication.Documents.Open(oPartDescriptor.FullDocumentName, False) Else ' Använd den redan öppna dokumentreferensen oPartDoc = oPartDescriptor.ReferencedDocument End If ' Sätt iProperty "Revision Number" i den kopplade partfilen iProperties.Value(oPartDoc,"Project","Revision Number") = revision MessageBox.Show("Revisionsbokstaven har uppdaterats till: " & revision, "Uppdatering Klar")
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Hi @Gwennberg. Try changing the following line in your code:
iProperties.Value(oPartDoc,"Project","Revision Number") = revision
...to be like this:
iProperties.Value(oPartDoc.DisplayName,"Project","Revision Number") = revision
...because that first (of 3) inputs is wanting a String. Sometimes the Document.DisplayName property value will work there, and if not, you can try extracting the file name (no file path) of that document, and using that in that position.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.