Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
helouise
1338 Views, 10 Replies

Help, Check if Part number = Filename, Change Case and add Stock Number.

Hi All, I just started playing with iLogic and reading through all Forum posts to edit code to accomplish what I need.

 

We use Part1,Part2 etc. to name our parts and can include extra info after for example Part1 70x70x6 Angle

 

I have the following code that checks if part number is the same as file name then change Part number to Upper Case and if the Part number includes "PART"  I get the number of the part and set it to Stock Number (As I only want to set Stock number for certain parts)

If Part number is not the Same it Changes it to file name and does the rest.

 

The Reason I am Getting the Stock Numbers is for my Parts Lists as I cant be certain Item numbers In BOM is same as Part Number and 99% of the time I have to set it Manually and keep making sure it is correct by enabling the part number in parts list checking and the removing part number again.

 

I set the Rule to Run After Open Document Trigger to make sure all Parts Assemblies and drawings have the Correct Part Number to Stop Errors from occurring in our drawings.

 

Our Parts Lists have Columns ITEM(Where I will now use Stock Number), Description, Mass and Material.

So Stock Number will now be used in our Balloons and Part detail labels Will Use Stock Number.

 

Sorry for the long Explanation, Here is my Question.

 

If the Part Number is Already the same as Filename and is set to Uppercase and Stock Number is Correct, can I stop it From Doing it again and again every time I open that File. So Basically just Check and Exit if it is Correct.

 

Stopping it from changing it every time will Reduce Processing time Immensely.

If my code is messy any Tips would be great!!

 

Before Rule

Before Rule.png

 After Rule

After Rule.png

 

Thank you

 

oDoc = ThisDoc.FileName(False)
PartNumber = iProperties.Value("Project", "Part Number")

If  UCase(PartNumber) = UCase(oDoc)
	iProperties.Value("Project", "Part Number") = UCase(iProperties.Value("Project", "Part Number"))
	
If  iProperties.Value("Project", "Part Number").Contains("PART") Then
	GetString = Split(iProperties.Value("Project", "Part Number"), " ")
	'Get First String Of Part Number, Get String from 5th Character(Starting Position), 5 Characters
	iProperties.Value("Project", "Stock Number") = Mid(GetString(0), 5, 5)
End If
    Return

Else

	iProperties.Value("Project", "Part Number") = oDoc
	iProperties.Value("Project", "Part Number") = UCase(iProperties.Value("Project", "Part Number")) 
End If

If 	iProperties.Value("Project", "Part Number").Contains("PART") Then

	GetString = Split(iProperties.Value("Project", "Part Number"), " ")
	iProperties.Value("Project", "Stock Number") = Mid(GetString(0), 5, 5)
End If

P.S. This was Compiled from Different posts about different changes adapted to fit my needs