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: 

kDrawingDocumentObject Usage failure

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Ktomberlin
1112 Views, 3 Replies

kDrawingDocumentObject Usage failure

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

 

3 REPLIES 3
Message 2 of 4
jdkriek
in reply to: Ktomberlin

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
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 4
Ktomberlin
in reply to: jdkriek

Thank you, I made that change and it does work now for both drawings and parts. I don't quite understand why when it is run on a part file it even looks at the lines inside of the drawing section.
Message 4 of 4
jdkriek
in reply to: Ktomberlin

Glad that worked for you.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


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

Post to forums  

Autodesk Design & Make Report