iLogic - Change part number from assembly level

iLogic - Change part number from assembly level

Anonymous
Not applicable
553 Views
2 Replies
Message 1 of 3

iLogic - Change part number from assembly level

Anonymous
Not applicable

Hey,

 

We had rules in every part and assembly, now we are trying to change this to 1 rule in the main assembly.

Found a good working rule and added some other properties to it but i'm stuck on the part number

 

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  

	'get the units of measure
    Dim oUOM As UnitsOfMeasure
    oUOM = oOccurrence.Definition.Document.UnitsOfMeasure

	'check for and skip virtual components
	'(in case a virtual component trips things up)
	If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
		map = Left(ThisDoc.FileName(False),6) & ".xlsx"
		xls = "C:\VaultWorkspace\Projecten"
		info = xls & "\" & map
		Dim Aream As String 
		Aream = Round(iProperties.AreaOfComponent(oOccurrence.Name)/1000000,2)
		 ' Convert the Area to the current document units.
   		Dim strArea As String
    	strArea = Aream & "m²"
		
		'push properties to component's iprops
		iProperties.Value(oOccurrence.Name, "Custom", "Aream") = strArea 		
		iProperties.Value(oOccurrence.Name, "Summary", "Title") = GoExcel.CellValue(info, "Pro-info","C10")
		iProperties.Value(oOccurrence.Name, "Summary", "Subject") = GoExcel.CellValue("C11")
		iProperties.Value(oOccurrence.Name, "Summary", "Manager") = GoExcel.CellValue("C41")
		iProperties.Value(oOccurrence.Name, "Project", "Project") = GoExcel.CellValue("C39")']
		iProperties.Value(oOccurrence.Name, "Custom", "Klant") = GoExcel.CellValue("C33")
		iProperties.Value(oOccurrence.Name, "Custom", "Projectnaam") = GoExcel.CellValue("C10")
		iProperties.Value(oOccurrence.Name, "Custom", "Subbeschrijving") = GoExcel.CellValue("C11")
		iProperties.Value(oOccurrence.Name, "Project", "Part Number") = Mid (oOccurrence.Name(0),8,12)
		iProperties.Value(oOccurrence.Name, "Custom", "Aantal") = ItemQty
	End If
Next

	' add properties to head assembly where rule is activated
	iProperties.Value("Custom", "AREAm") = (Round(iProperties.Area / 1000000,2)) & "m²"
	iProperties.Value("Summary", "Title") = GoExcel.CellValue(info, "Pro-info","C10")
	iProperties.Value("Summary", "Subject") = GoExcel.CellValue("C11")
	iProperties.Value("Summary", "Manager") = GoExcel.CellValue("C41")
	iProperties.Value("Project", "Project") = GoExcel.CellValue("C39")']
	iProperties.Value("Custom", "Klant") = GoExcel.CellValue("C33")
	iProperties.Value("Custom", "Projectnaam") = GoExcel.CellValue("C10")
	iProperties.Value("Custom", "Subbeschrijving") = GoExcel.CellValue("C11")
	GoExcel.Save
	GoExcel.Close

This is what we had in our old rule:

 

 

iProperties.Value("Project", "Part Number") = Mid (ThisDoc.FileName(0),8,12)

But changing  ThisDoc.fileName to oOccurence.name does not work

 

Thanks

 

0 Likes
Accepted solutions (1)
554 Views
2 Replies
Replies (2)
Message 2 of 3

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

Dag @Anonymous

Why is that zero in your code? This works...

Mid(oOccurrence.Name,8,12)

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 3 of 3

Anonymous
Not applicable
Oh i see, i forgot to remove the argument from the old function
Thanks!
0 Likes