Community
Due to a MRP issue. we have to now add a new custom property to some files for drawing purposes. This code works if run on a drawing but posts an error on parts or assemblies,
ThisDrawing: This document "P054002-P010025-010-125-050-1-W-1" is not a drawing.
Anyone have the change i need to make this work for all docment types?
'Inputing New DetailViewName doc = ThisDoc.ModelDocument 'doc = ThisDoc.Document Dim MyDetailViewName As String Dim CurrentPN As String If doc.DocumentType = kDrawingDocumentObject Then Goto Drawing 'Else If doc.DocumentType = kPartDocumentObject Then Else Goto Other End If Return Drawing: modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
CurrentPN = iProperties.Value(modelname, "Project", "Part Number") Try MyDetailViewName = iProperties.Value(modelName, "Custom", "Detail_Part_Number") Catch ' Assume error means not found iProperties.Value(modelName, "Custom", "Detail_Part_Number")= CurrentPN MyDetailViewName = iProperties.Value(modelName, "Custom", "Detail_Part_Number") End Try MyDetailViewName = InputBox("Enter New Detail View Part Number.", "Part Number Needs to be Entered!", MyDetailViewName) iProperties.Value(modelName, "Custom", "Detail_Part_Number") = MyDetailViewName Goto Ending Other: CurrentPN = iProperties.Value("Project", "Part Number") Try MyDetailViewName = iProperties.Value("Custom", "Detail_Part_Number") Catch ' Assume error means not found iProperties.Value("Custom", "Detail_Part_Number")= CurrentPN MyDetailViewName = iProperties.Value("Custom", "Detail_Part_Number") End Try MyDetailViewName = InputBox("Enter New Detail View Part Number.", "Part Number Needs to be Entered!", MyDetailViewName) iProperties.Value("Custom", "Detail_Part_Number") = MyDetailViewName Goto Ending Return Ending: Return ' 'update the file iLogicVb.UpdateWhenDone = True
Solved! Go to Solution.
Solved by jdkriek. Go to Solution.
As long as you are doing a check on the document type you can use ThisDoc rather than ThisDrawing
modelName = IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)
Example:
doc = ThisDoc.Document
'12292 Drawing Document
If doc.DocumentType = 12292 Then
modelName = IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)
MsgBox(modelName)
End If