Hi,
I have the following code to clean up iProperties in idw files.
If ThisDoc.Document.documenttype=12292 Then doc = ThisDrawing.ModelDocument iProperties.Value("Project", "Revision Number") = doc.PropertySets.Item(1).Item("Revision Number").Value iProperties.Value("Project", "Part Number")= "" iProperties.Value("Project", "Description")= "" iProperties.Value("Summary", "Title")="" iProperties.Value("Summary", "Subject")="" iProperties.Value("Summary", "Author")="" iProperties.Value("Project", "Project")= "" iProperties.Value("Project", "Designer")= "" iProperties.Value("Project", "Engineer")= "" iProperties.Value("Project", "Authority")= "" iProperties.Value("Project", "Cost Center")= "" iProperties.Value("Project", "Creation Time")= #1/1/1601# iProperties.Value("Status", "Status")="" iProperties.Value("Status", "Checked By")="" iProperties.Value("Status", "Checked Date")= #1/1/1601# iProperties.Value("Status", "Engr Approved By")="" iProperties.Value("Status", "Engr Date Approved")=#1/1/1601# iProperties.Value("Status", "Mfg Approved By")="" iProperties.Value("Status", "Mfg Date Approved")=#1/1/1601# End If
For some reason, when this code runs, it always trys to execute the doc=ThisDrawing.ModelDocument, regardless of whether or not the IF statment condition is true. I have no idea what is wrong here.
I am running Inventor 2012, SP2
Thank you for your help.
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi ilotey,
I think you want the second line to read:
doc = ThisDoc.ModelDocument
rather than:
doc = ThisDrawing.ModelDocument
This snippet seems to work for me:
If ThisDoc.Document.documenttype=12292 Then
doc = ThisDoc.ModelDocument
iProperties.Value("Project", "Revision Number") = _
doc.PropertySets.Item(1).Item("Revision Number").Value
iProperties.Value("Project", "Part Number")= ""
iProperties.Value("Project", "Description")= ""
iProperties.Value("Summary", "Title")=""
iProperties.Value("Summary", "Subject")=""
iProperties.Value("Summary", "Author")=""
iProperties.Value("Project", "Project")= ""
iProperties.Value("Project", "Designer")= ""
iProperties.Value("Project", "Engineer")= ""
iProperties.Value("Project", "Authority")= ""
iProperties.Value("Project", "Cost Center")= ""
iProperties.Value("Project", "Creation Time")= #1/1/1601#
iProperties.Value("Status", "Status")=""
iProperties.Value("Status", "Checked By")=""
iProperties.Value("Status", "Checked Date")= #1/1/1601#
iProperties.Value("Status", "Engr Approved By")=""
iProperties.Value("Status", "Engr Date Approved")=#1/1/1601#
iProperties.Value("Status", "Mfg Approved By")=""
iProperties.Value("Status", "Mfg Date Approved")=#1/1/1601#
End If
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thanks Curtis, that seems to have worked.
But why does Inventor try to evaluate ThisDrawing.ModelDocument even though the IF condition is not satisified?
-Iqbal.