Changing iProperties of an iPart from an Assembly

Changing iProperties of an iPart from an Assembly

dkrenz7SLFV
Explorer Explorer
259 Views
4 Replies
Message 1 of 5

Changing iProperties of an iPart from an Assembly

dkrenz7SLFV
Explorer
Explorer

Is it possible to change the iProperties of the parent iPart from an assembly? I found and modified this rule but it doesn't work very well with iParts. Is there a way to make this work with iParts?

0 Likes
260 Views
4 Replies
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

How are you using the factory file (Parent iPart), In a library? Or are you using the factory file only? What would the reason be behind changing factory file by code? If in the library setting, that is a manual operation done in the factory file table.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 5

dkrenz7SLFV
Explorer
Explorer

We create parts out of lengths of extrusions. Each member is a different length with a different configuration of holes and cuts. Each part is then put into an assembly with parts from different extrusions and iPart factories. Our customer has come back and asked if we can add the die profile number to the information that we give them. With regular parts, we can edit this information in the BOM, but with iParts you can't edit the information in the BOM. So we are looking for a way to add this information without opening each individual iPart factory and manually changing it. Hopefully this makes sense.

0 Likes
Message 4 of 5

A.Acheson
Mentor
Mentor

It can be done but updating the factory file can be difficult as you need to work out where you are in the table via rows and columns and then update the generated file. 

A few more questions.

1. Is the factory file in a library folder meaning it’s read only and needs a project file change to edit? Or is it in the workspace/ a writeable path?

Here is a link to get you started. 

It is written in VBA and access directly the table. 

 

https://adndevblog.typepad.com/manufacturing/2013/02/manipulate-rows-and-columns-of-ipart-1.html



 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 5

A.Acheson
Mentor
Mentor

Here is a rule that seems to work consistently. This rule will update the factory iPart located in either the workspace of location that is not a library and where the factory iPart is writeable. 

 

To add more iProperties just add another inputbox, sub routine call and adjust the column title requiring editing.

	 ChangeFactoryValue(oPartDoc, "Part Number", PartNo)'Adjust string value "Part Number"

Working Rule:

Sub Main
	
	Dim PartNo As String = InputBox("Prompt", "Part Number", "Default Entry")
	
	Dim Desc As String = InputBox("Prompt", "Description", "Default Entry")
	
	Dim oAssyDoc As AssemblyDocument = ThisDoc.Document

	Dim oPartoOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Part")
	
	If oPartoOcc Is Nothing Then 
		Exit Sub
    ElseIf oPartoOcc.Definition.Type = ObjectTypeEnum.kPartComponentDefinitionObject
	   
	 Dim oPartDoc As PartDocument = oPartoOcc.Definition.Document
	'Adjust the inputs to the factory table
	 ChangeFactoryValue(oPartDoc, "Part Number", PartNo)'Adjust string value "Part Number"
	 ChangeFactoryValue(oPartDoc, "Description", Desc)
 
    Else
		MsgBox("Not a Part Exiting.", vbExclamation, "Occurrence Check") 
	 	Exit Sub
	End If
	oAssyDoc.Update
	
End Sub



Sub ChangeFactoryValue(oPartDoc As PartDocument, ColHeader As String, CellValue As String)

    Dim oCompDef As PartComponentDefinition 
	Dim oFactoryDoc As PartDocument

	If oPartDoc.ReferencedDocumentDescriptors.Count = 0 Then
		MsgBox("Chosen document is not a factory.", vbExclamation,"Document Check")
		Exit Sub
	Else
		oCompDef = oPartDoc.ReferencedDocumentDescriptors(1).ReferencedDocument.ComponentDefinition
	
		If oCompDef.IsiPartFactory = False Then
    		MsgBox ("Chosen document is not a factory. factory check", vbExclamation,"Document Check")
    		Exit Sub
		ElseIf oCompDef.IsiPartFactory = True
	 		oFactoryDoc = oPartDoc.ReferencedDocumentDescriptors(1).ReferencedDocument
		End If
	End If

	Dim sFileName As String = IO.Path.GetFileNameWithoutExtension(oPartDoc.FullFileName)
	
    Dim oFactory As iPartFactory = oCompDef.iPartFactory
 	
	Dim iRow As Integer
	For iRow = 1 To oFactory.TableRows.Count
		If oFactory.FileNameColumn.Item(iRow).Value = sFileName Then
			Exit For
		End If
	Next
    For Each oEachCol As iPartTableColumn In oFactory.TableColumns
		Try
		If oEachCol.DisplayHeading = ColHeader Then
			Try
			oEachCol.Item(iRow).Value = CellValue
			Catch
				MsgBox ("Problem updating factory, It could be in a Library and Read Only", vbExclamation,"Document Check")
			End Try
		End If
		Catch
		End Try
	Next

	oFactoryDoc.Rebuild

End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes