Climbing the tree
In this post, I’ll show how to climb the tree bottom-up, and how this allows reactions or actions to be more independent from the tree and re-usable in a different context.
Moving up along the tree is possible using Owner attribute, GetPLMOwner, AggregationReference attribute or setting False the down input of the function Find (True is looking for the children, while False is looking at its owners).
P.S this post was part of a series of posts realized for 3dxautomation.com that unfortunately was shouted down.
Tools — 3dExperience, EKL
Moving up along the tree
Let myRef, myRoot (VPMReference) Let myInst (VPMInstance) Let my3Dsh (`3DShape`) Let myDrw (Drawing) Let myGeoSet (OpenBodyFeature) Let myPt (Point) Let refList (List) myRoot = GetEditorRoots("VPMReference").GetItem(1) //Using find looking down myPt = myRoot.Find("Point", "", true) Message("Point Name: #|Point Owner: #", myPt.Name, myPt.Owner.Name()) //Using find looking up myGeoSet = myPt.Find("OpenBodyFeature", "", false) Message("GeoSet Name: #|GeoSet Owner: #", myGeoSet.Name, myGeoSet.Owner.Name()) /* Using Owner attribute we can't go further than this, because it doesn't allow you to go higher than PartFeature so to reach the PLM Entity 3D Shape we should use GetPLMOwner */ my3Dsh = GetPLMOwner(myGeoSet) Message("3DShape Name: #|3DShape Owner: #", my3Dsh.V_Name, my3Dsh.Owner.Name()) // AggregatingReference pass a VPMCoreReference so we have to cast for having a VPMReference */ myRef = my3Dsh.AggregatingReference : VPMReference Message("myRef Name: #|myRef Owner: #", myRef.V_Name, myRef.Owner.Name()) // Get the instance of the Reference myInst = myRef.ListInstances(myRoot).GetItem(1) Message("myInst Name: #|myInst Owner: #", myInst.Name, myInst.Owner.Name()) myDrw = myRoot.Find("Drawing", "", true) Message("Drw Name: #|Drw Owner: #", myDrw.Name, myDrw.Owner.Name()) //Drawing is the Owner of the sheet Let myDrw (Feature) Let mySheet (DrwSheet) myDrw = GetRootUI() mySheet = myDrw.Find("DrwSheet", "", True) Message("Sheet Name: #|Sheet Owner: #", mySheet.Name, mySheet.Owner.Name())
Access a UDF to modify its properties
In this example, we are showing how to access the UDF, once instantiated, by a reaction within the UDF.
Using the Owner attribute to the Relations we move up to the tree and we obtain the UserFeature.
Once retrieved, we can modify the visibility or proprieties of the outputs which wouldn’t be accessible outside the UDF.
let myRef (VPMReference) let o3Shape (`3DShape`) let oGeo (OpenBodyFeature) let myUDF (UserFeature) let parType, parColor (String) let plate, bracket, pin (VolumeGeo) //Using the attribute Owner to the Relations retrieves the UserFeature once is instanciated. myUDF = Relations.Owner : UserFeature oGeo = myUDF.Owner : OpenBodyFeature //Getting the output object and paramenters of the UDF parType = myUDF.GetAttributeString("Type") parColor = myUDF.GetAttributeString("Color") plate = myUDF.GetAttributeObject("PlateWithSlots") bracket = myUDF.GetAttributeObject("BracketWithSlots") pin = myUDF.GetAttributeObject("PlateWithPin") if parType == "Plate" { plate.Show = true bracket.Show = false pin.Show = false plate.Color = parColor } else if parType == "Bracket" { plate.Show = false bracket.Show = true pin.Show = false bracket.Color = parColor } else { plate.Show = false bracket.Show = false pin.Show = true pin.Color = parColor }
Starting from a reaction
Here we instantiate a Power Copy which has a reaction and Knowledge pattern.
Moving up from the reaction using GetPLMOwner we retrieve the PLMEntity 3DShape and from there we move down searching for the KP and trigger it.
This allows maintaining relations more flexibly and reusable for different projects.
Let oKp (KnowledgePattern) Let o3sh (`3DShape`) // Moving Up looking for the 3DShape o3sh = GetPLMOwner(parameter) //Moving Down looking for the Knowledge Pattern oKp = o3sh.Find("KnowledgePattern", "", True) oKp.Update()