@maxim.teleguz wrote:
the issue is check to see if it exists, because we want to reuse the existing parameter if it exists.
You are assuming we always want to re-write that parameter.
....though you showed us some really cool tricks I haven't seen yet.
Hi @maxim.teleguz ,
I wasn't speaking about parameters, but about iProperties, and my reply wasn't assuming anyone's intent, but just sharing some information and attempting to provide some clarification in case it helps someone.
But to your point, you are correct, the 1st example does both check and set the iproperty, as I stated previously. If the intent was not to set the value, then that would indeed not be the right choice to use.
The 2nd, 3rd, and 4th examples I shared, all check for the existence of the iproperty, but don't set it.
There are several combinations of using the iLogic iProperties function to get and set a custom iproperty that can be used for different tasks. And understanding what the iLogic iProperties function is doing in each case is helpful in knowing what to include and exclude, and when to do so.
As an example, in post 4 and 7 of this thread, the "if iprop = nothing" statement you used in the Try statement is not necessary, because the ilogic iPropertiy function is doing the check already.
So you could eliminate that if you wanted to do so, and just use something like this, which is similar to Sergio's example in post 2
Try
'if not exist causes error
oTest = iProperties.Value("Custom", "Ref. Number")
Catch
'create it
iProperties.Value("Custom", "Ref. Number") = ""
End Try
Or maybe even something like this:
p = "Ref. Number"
Try : x = iProperties.Value("Custom", p) : Catch : iProperties.Value("Custom", p) = "" : End Try
In any case, since the original question was about Date parameters, I have marked the posts that addressed the date type mismatch issue as solutions.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com