iLogic Additional screws with rectangular series

iLogic Additional screws with rectangular series

v_zanetti_duea
Participant Participant
206 Views
4 Replies
Message 1 of 5

iLogic Additional screws with rectangular series

v_zanetti_duea
Participant
Participant

Dear Forum, sorry for my poor English.

It is possible with ilogic to search on the BOM Parts Only in the assembly where the rule is executed, all the members that are from the content center.

 

When I found the member of the content center, write in logger.info these properties of the BOM: INFO: Part Number | Description | QTY |

The qty (the quantity of that part number) will be used to evaluate the formula. Insert the found member and place it on X0 Y0 Z0, fix it and remove the visibility.


Create the Parameter("L_series") = 1 mm (which will always be 1 mm)

Create a rectangular series in the column of the member in the Z direction, evaluate the spacing with Parameter("L_series"), then evaluate the number of columns with this formula: qty*10/100

 

Then search for the next one until they are all placed in the main assembly and create the rectangular array for each one of the placed components. The name of the series will be the description of the component then the series will be not visible.

If it were possible,
Thank you
 

0 Likes
Accepted solutions (1)
207 Views
4 Replies
Replies (4)
Message 2 of 5

C_Haines_ENG
Collaborator
Collaborator

What are you doing this for? What will this code achieve for you? 

0 Likes
Message 3 of 5

v_zanetti_duea
Participant
Participant

This code will help me add a percentage of additional screws to the project I'm designing without having to manually search in the assemblies and subassemblies.
So my idea was:
1) I search for all those screws that are part of the content center in the assemblies and subassemblies
2) I count them and add them to the main assembly on XYZ0 fixed
3) I create a rectangular series for each screw added only in the column with a percentage equal to 2% for some screws and 10% for other screws, with the possibility of having a list in ilogic to choose which calculation to do (a "Case" or an "If" I already know the part numbers to make it do the different calculation, or the local path for the entire family of screws). The name of the series will have the description of the added component.
4) I remove the visibility of all the inserted series
5) (I don't know if this is possible) I move the series into a folder in the browser called "Additional_Screws"
6) I write everything in the logger to have a clear idea of ​​the calculation that has been done and what has been added. This way when I have big projects I can quickly check

0 Likes
Message 4 of 5

C_Haines_ENG
Collaborator
Collaborator

I wrote This Code for another user with a similar issue to yours. Maybe you can use it to build a program to better fit your needs?

0 Likes
Message 5 of 5

v_zanetti_duea
Participant
Participant
Accepted solution

Thanks, in the meantime I wrote something but I couldn't do point 5. If it can be useful to someone, I will write the rule below and if we can update it with point 5 that would be great.

 

' Content Center Directory
Dim contentCenterPath As String = "C:\@Vault\Content Center Files"	' "Enter the path to your local content center here"
Dim specificPath1 As String = "C:\@Vault\Content Center Files\it-IT\ISO 4014"	' "Enter the specific path for the different calculation here"
Dim specificPath2 As String = "C:\@Vaul\Content Center Files\it-IT\ISO 8677"	' "Enter the specific path for the different calculation here"

Dim oAssembly As AssemblyDocument = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition = oAssembly.ComponentDefinition
Dim oBOM As BOM = oDef.BOM

oBOM.PartsOnlyViewEnabled = True

Dim oUserParams As UserParameters = oDef.Parameters.UserParameters
Dim oParam_L_series As UserParameter

Try
	oParam_L_series = oUserParams.Item("L_series")
Catch
	oParam_L_series = oUserParams.AddByExpression("L_series", "1 mm", UnitsTypeEnum.kMillimeterLengthUnits)
End Try

Dim L_series_value As Double = 1 
Try
	L_series_value = oParam_L_series.Value
Catch ex As Exception
	Logger.Error("Error while retrieving value of parameter 'L_series': " & ex.Message)
End Try

Dim oBOMView As BOMView = oBOM.BOMViews.Item("Parts Only")
For Each oRow As BOMRow In oBOMView.BOMRows
	If oRow.ComponentDefinitions.Count > 0 Then
		Dim oCompDef As ComponentDefinition = oRow.ComponentDefinitions(1)
		Dim oDoc As Document = oCompDef.Document

		Dim isFromContentCenter As Boolean = oDoc.FullFileName.StartsWith(contentCenterPath, StringComparison.OrdinalIgnoreCase)

		If isFromContentCenter Then
			Try
				Dim oPartNumber As String = oRow.ItemNumber
				Dim oDescription As String = oDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value
				Dim oQuantity As Integer = oRow.ItemQuantity

				Logger.Info(String.Format(" {1} | {2}", oPartNumber, oDescription, oQuantity))

				Dim oMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()

				Dim oOcc As ComponentOccurrence = oDef.Occurrences.Add(oDoc.FullFileName, oMatrix)
				oOcc.Grounded = True
				oOcc.Visible = False

				Dim oCalculation As Integer
				If oDoc.FullFileName.StartsWith(specificPath1, StringComparison.OrdinalIgnoreCase) Then
					' Specific calculation for file specific Path 1
					oCalculation = Math.Ceiling(oQuantity * 35 / 100)
				ElseIf oDoc.FullFileName.StartsWith(specificPath2, StringComparison.OrdinalIgnoreCase) Then
					' Specific calculation for file specific Path 2
					oCalculation = Math.Ceiling(oQuantity * 35 / 100)
				Else
					' Default calculation
					oCalculation = Math.Ceiling(oQuantity * 2 / 100)
				End If

				Dim oTO As TransientObjects = ThisApplication.TransientObjects
				Dim oObjects As ObjectCollection = oTO.CreateObjectCollection
				oObjects.Add(oOcc)

				Dim oColumnEntity As Object = oDef.WorkAxes.Item(2)
				Dim oPatt As RectangularOccurrencePattern
				Try
					oPatt = oDef.OccurrencePatterns.AddRectangularPattern(oObjects, oColumnEntity, True, _
					L_series_value, oCalculation)
					oPatt.Name = oDescription 
					oPatt.Visible = False 
				Catch ex As Exception
					Logger.Error("Error creating rectangular array for '" & oDescription & "': " & ex.Message)
				End Try
			Catch ex As Exception
				Logger.Error("Error processing component: " & ex.Message)
			End Try
		End If
	End If
Next
0 Likes