iLogic Copy Value if between range otherwise leave blank

iLogic Copy Value if between range otherwise leave blank

GKPByDesign
Advocate Advocate
700 Views
7 Replies
Message 1 of 8

iLogic Copy Value if between range otherwise leave blank

GKPByDesign
Advocate
Advocate

I require two ilogic rules to be created that I simply cannot get my head round, I require these two rules to do the following:

 

Custom iProp Angle_1 entered by user,

 

If iProp Angle_1 is between 1-89 degrees the same value is copied to custom iProp Angle_2. eg Angle_1 = 56 Degrees then Angle_2 is the same at 56 degrees.

 

But if iProp Angle_1 is 1 or 90 degrees iProp Angle_2 remains blank (no text)

 

The second code:

 

Custom iProp Model_Type_1,

 

If Model_Type_1 is Model A,  Model B, Model C, or Model D, value for custom iProp Model_Type 2 will equal the same value. eg Model_Type_1 = Model B, Model_Type_2 also equals Model B. 

 

But if Model_Type_1 is "None" (written as none) then Model_Type_2 is blank. (no text)

 

Can someone help me, I have just input over 2200 cell datas, my head is fried! 

0 Likes
Accepted solutions (1)
701 Views
7 Replies
Replies (7)
Message 2 of 8

Sergio.D.Suárez
Mentor
Mentor

Hi, I think this rule does what you need. I have not tried it in depth. I hope it works well
If you have a property with a value of "59 gr", or "59 degrees", or "59 º". The rule will look for the space "" and separate the string to extract the number. Then compare this number and according to the conditions you mentioned you will overwrite the value of the second property.

1.jpg

Dim oDoc As Document = ThisDoc.Document
Dim oPropSets As PropertySets 
oPropSets = oDoc.PropertySets 
on error resume next
oCustomAngle_1 = oPropSets.Item("Inventor User Defined Properties").Item("Angle_1").Value
NumberAngle_1 = Left(oCustomAngle_1, (InStrRev(oCustomAngle_1, " ", - 1, vbTextCompare) - 1))
oExtension = Right(oCustomAngle_1, Len(oCustomAngle_1) - InStrRev(oCustomAngle_1, " "))


If 1 < NumberAngle_1 < 89 Then
	oPropSets.Item("Inventor User Defined Properties").Item("Angle_2").Value = NumberAngle_1 & " " & oExtension
End If
If NumberAngle_1 = 1 Or NumberAngle_1 = 90 Then
	oPropSets.Item("Inventor User Defined Properties").Item("Angle_2").Value = "0 " & oExtension
End If

 Regarding the second action I think that this rule could work.
If the first property says "None" it will put "" on the second property. If the first property has a value, it will place the same value in the second property

Dim oDoc As Document = ThisDoc.Document
Dim oPropSets As PropertySets 
oPropSets = oDoc.PropertySets 

oModel_Type_1 = oPropSets.Item("Inventor User Defined Properties").Item("Model_Type_1").Value

If oModel_Type_1 = "Ninguno" Then
	oPropSets.Item("Inventor User Defined Properties").Item("Model_Type_2").Value = ""
Else
	oPropSets.Item("Inventor User Defined Properties").Item("Model_Type_2").Value = oModel_Type_1
End If

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 8

GKPByDesign
Advocate
Advocate

Hey It is definitely doing something, but not do the second part

 

So the range I need is 0.5 - 89.5,

 

But if the values are 0.5 or 89.5 then the answer needs to be blank

 

eg,

Angle_1 = 46, Angle_2 = 46

 

OR

 

Angle_1 = 89.5, Angle_2 = (Blank) not zero

 

It doesn't seem to be doing this. I will look at the other code now. 

 

Thank you 

0 Likes
Message 4 of 8

GKPByDesign
Advocate
Advocate

The second code I do not need now, I have superseded it. But the angle one is still not leaving a blank value at two septic angles. Help please!

 

Range between 0.5 - 89.5 equal's the same value for a custom iprop

if 0.1 or 89.9 then value in custom I prop is blank. 

0 Likes
Message 5 of 8

Anonymous
Not applicable

you  can make a range like this

 

I use a sample this should work...

 

dim myparam as Integer

myparam = InputBox("Prompt", "Title", "Default Entry")



If myparam > 100 And myparam < 150 Then
	
	MsgBox("happy")
	
Else

 MsgBox("bad luck")
 
 End If
0 Likes
Message 6 of 8

Sergio.D.Suárez
Mentor
Mentor

Hi, if the angle is written without your unit, only the numerical value, it is easier, you could use a rule like the one I show you below

 

1.jpg

Dim oDoc As Document = ThisDoc.Document
Dim oPropSets As PropertySets 
oPropSets = oDoc.PropertySets 
On Error Resume Next
oCustomAngle_1 = oPropSets.Item("Inventor User Defined Properties").Item("Angle_1").Value
If 0.5 < oCustomAngle_1 < 89.5 Then
	oPropSets.Item("Inventor User Defined Properties").Item("Angle_2").Value = oCustomAngle_1
End If
If oCustomAngle_1 = 0.5 Or oCustomAngle_1 = 89.5 Then
	oPropSets.Item("Inventor User Defined Properties").Item("Angle_2").Value = " "
End If

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 7 of 8

GKPByDesign
Advocate
Advocate

I will try this tonight, I don't need the units so it may be a good solution

0 Likes
Message 8 of 8

Curtis_Waguespack
Consultant
Consultant
Accepted solution

 

Hi @Anonymous 

 

Welcome to the forum. You can use the "AndAlso" operator for this too.

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/operator-statement

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oAngle_1 = iProperties.Value("Custom", "Angle_1")


If oAngle_1 >= 0.5  AndAlso oAngle_1 <= 89.5 Then

	iProperties.Value("Custom", "Angle_2") = oAngle_1
	
Else 

	iProperties.Value("Custom", "Angle_2") = " "


End If

EESignature