Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic rule will always accept save regardless changes or not

3 REPLIES 3
Reply
Message 1 of 4
tegstette
316 Views, 3 Replies

iLogic rule will always accept save regardless changes or not

Hello

 

Hope someone can help me with this iLogic rule.

 

I am not good with iLogic but I have this rule that gives me length and width of a sheetmetal part in mm and with , (comma). The rule works but the file will always accept saving regardless if there has been changes or not. I want the rule to only accept save IF there has been changes on SM_Length (=<FLAT PATTERN LENGTH> cm) and SM_Width (=<FLAT PATTERN WIDTH> cm) or Thickness.

 

Is this possible?

   

 

sLength = iProperties.Value("Custom", "SM_Length")

sWidth = iProperties.Value("Custom", "SM_Width")

sThickness = iProperties.Value("Custom", "Thickness")

 

sLength = sLength * 10

sLength = Replace(sLength,".",",")

sLength = Replace(sLength," mm","")

 

sWidth = sWidth * 10

sWidth = Replace(sWidth,".",",")

sWidth = Replace(sWidth," mm","")

 

 

sThickness = Replace(sThickness,".",",")

sThickness = Replace(sThickness," mm","")

sThickness = Round(CDbl(sThickness),1)

 

iProperties.Value("Custom", "Length") = CStr(sLength)

iProperties.Value("Custom", "Width") = CStr(sWidth)

iProperties.Value("Custom", "Thickness") = CStr(sThickness)

 

 

Best Regards

TEG

Best regards
TG

Autodesk Inventor/Vault Professional 2021
3 REPLIES 3
Message 2 of 4
MegaJerk
in reply to: tegstette

So you're changing the values of your iproperties to get the part to update, correct? 

I would create another set of iproperties for SM_Length / SM_Thickness / SM_Width 

Let's call them 

 

SM_Length_Old
SM_Width_Old
SM_Thickness_Old

 

Then I would change the code so that it would update those values at the end of the code, but look to make sure that they aren't equal at the beginning. 

Dim SM_Length, SM_Width, Thickness, SM_Length_Old, SM_Width_Old, Thickness_Old As Double

SM_Length = iProperties.Value("Custom", "SM_Length")
SM_Width = iProperties.Value("Custom", "SM_Width")
Thickness = iProperties.Value("Custom", "Thickness") 

SM_Length_Old = iProperties.Value("Custom", "SM_Length_Old")
SM_Width_Old = iProperties.Value("Custom", "SM_Width_Old")
Thickness_Old = iProperties.Value("Custom", "Thickness_Old") 

If SM_Length_Old <> SM_Length Or SM_Width_Old <> SM_Width Or Thickness_Old <> Thickness Then 

	sLength = SM_Length
	sWidth = SM_Width
	sThickness = Thickness 

	sLength = sLength * 10
	sLength = Replace(sLength,".",",")
	sLength = Replace(sLength," mm","")
	 
	sWidth = sWidth * 10
	sWidth = Replace(sWidth,".",",")
	sWidth = Replace(sWidth," mm","")

	sThickness = Replace(sThickness,".",",")
	sThickness = Replace(sThickness," mm","")
	sThickness = Round(CDbl(sThickness),1)

	iProperties.Value("Custom", "Length") = CStr(sLength)
	iProperties.Value("Custom", "Width") = CStr(sWidth)
	iProperties.Value("Custom", "Thickness") = CStr(sThickness)

	SM_Length_Old = SM_Length
	SM_Width_Old = SM_Width
	Thickness = Thickness_Old
End If

 

*Note, I ended up making all of those declarations up there for your iprops into new vars, because I of the code window size restrictions. It ended up looking pretty cramped (unreadable) in the raw way, and all of those Or statements would have been silly. Also, I declared those are Doubles, as I am assuming that you're using a Number Type iProperty. 


I hope that this helps. 



 






If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 4
tegstette
in reply to: MegaJerk

Thank you very much for your answerSmiley Happy

 

I have tried it but my iprops are text and perhaps that is why I get these errors?

 

Do you have a tip for this?

 

 

Best regards

TEG

Best regards
TG

Autodesk Inventor/Vault Professional 2021
Message 4 of 4
MegaJerk
in reply to: tegstette

Just to be sure. You never confirmed your work flow. Are you updating the iProperties, and then hoping to update the User Parameters from those values, or the other way around?

If it's iProperties -> Parameters then you could just use this :

 

If  iProperties.Value("Custom", "SM_Length") <> sLength Or _
iProperties.Value("Custom", "SM_Width") <> sWidth Or _
iProperties.Value("Custom", "Thickness") <> sThickness Then 

	sLength = iProperties.Value("Custom", "SM_Length")
	sWidth = iProperties.Value("Custom", "SM_Width")
	sThickness = iProperties.Value("Custom", "Thickness") 
	
	sLength = sLength * 10
	sLength = Replace(sLength,".",",")
	sLength = Replace(sLength," mm","")
	
	sWidth = sWidth * 10
	sWidth = Replace(sWidth,".",",")
	sWidth = Replace(sWidth," mm","")
	
	
	sThickness = Replace(sThickness,".",",")
	sThickness = Replace(sThickness," mm","")
	sThickness = Round(CDbl(sThickness),1)
	
	iProperties.Value("Custom", "Length") = CStr(sLength)
	iProperties.Value("Custom", "Width") = CStr(sWidth)
	iProperties.Value("Custom", "Thickness") = CStr(sThickness)

End If 

 

I don't know why I didn't see that the first time around...

I tested that on your part (after turning d5, d6 into sLength and sWidth respectively, and creating a User Parameters called sThickness), and everything seemed to work fine. The body of the rule will not run unless you change those particular iproperty values, however, it should be kept in mind that you will dirty the part (make it so that it prompts you to save) if you change anything in the iProperties at all even if they don't involve those parameters. A change is a change!





If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub

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

Post to forums  

Autodesk Design & Make Report