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: 

ilogic if statement condition being ignored???

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ilotey
596 Views, 2 Replies

ilogic if statement condition being ignored???

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.

2 REPLIES 2
Message 2 of 3
Curtis_Waguespack
in reply to: ilotey

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

Message 3 of 3
ilotey
in reply to: ilotey

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.

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

Post to forums  

Autodesk Design & Make Report