When used interactively, the peer variable asks for an assembly component.
Similarly you can access the OccurrenceDocument or the OccurrenceFileName first and then seek its variables.
The ‘OccurrenceDocument’ object of an occurrence in the assembly can be used to access the peer variables of the occurrence part.
Open carrier.asm from the Solid Edge STxTraining folder and from the Tools tab start Variables. Note that there are just three variables in the assembly document itself.
However there are also 3 parts in the assembly and say you want to change the thickness of the SPlate.par without actually opening it.
To do this, start Peer Variables and select the Splate part from the PathFinder.
The Variable Table now reflects the variable for the Splate part. Some variables are grayed out while those with the white background are the ones that can be edited.
The V360 is the one for thickness of the plate.
The document variable should be declared as an AssemblyDocument:
Dim oDoc As SolidEdgeAssembly.AssemblyDocument = oApp.ActiveDocument
Access the required part from the assembly occurrences by either using its index number:
Dim oOccurrence As SolidEdgeAssembly.Occurrence = oDoc.Occurrences.Item(“2)
or its placement name as below:
Dim oOccurrence As SolidEdgeAssembly.Occurrence = oDoc.Occurrences.Item(“Splate.par:1”)
You can find the placement name of the occurrence by right-clicking it and selecting Occurrence Properties form the context menu.
Next step is to access the part document associated with the occurrence:
Dim oOccuPart As SolidEdgePart.PartDocument = oOccurrence.OccurrenceDocument
As you see, there is no need to actually open the part and access its variables.
The Part document is referenced directly from the occurrence and its variables are accessed:
Dim oVars As SolidEdgeFramework.Variables = oOccuPart.Variables
The remaining part to change the variable is fairly similar as seen in the Parametric Parts article:
oVars.Edit(“V360”, “24”) ‘ Older value = 20
oDoc.UpdateAll()
Finally, oDoc.UpdateAll() updates the assembly document and is equivalent to the Update All Links command
Give this powerful feature a try by building a simple Windows Forms application.