cancel
Showing results for 
Search instead for 
Did you mean: 

How to define a pose for equipment prototype programatically?

Valued Contributor
Valued Contributor

Hello,

 

I have created an equipment prototype and created two kinematic links and one joint :

Dim component As TxComponent = TxApplication.ActiveDocument.PhysicalRoot.CreateEquipment(New TxLocalComponentCreationData("equipment"))

Dim link1 As TxKinematicLink = component.CreateLink(New TxKinematicLinkCreationData("link1"))

Dim link2 As TxKinematicLink = component.CreateLink(New TxKinematicLinkCreationData("link2"))

Dim joint As TxJoint = component.CreateJoint(New TxJointCreationData() With {.ParentLink = link1, .ChildLink = link2, .Name = "j1", .JointType = TxJoint.TxJointType.Prismatic})

Than I have open and put in the equipment prototype some previously components with previously created kinematics:

 

Dim insList As New TxObjectList

Dim libDirectory As New IO.DirectoryInfo("...")

Dim cojts As IO.DirectoryInfo() = libDirectory.GetDirectories("v*.cojt")

Dim pmDocManager As New TxTunePmDocumentManager()

For Each cojt As IO.DirectoryInfo In cojts

    If cojt.Name.Contains(component.Name) Then Continue For

    Dim data As TxTunePmDocumentPrototypeData = pmDocManager.CreatePrototypeData("Fixture")

    IO.File.Delete(IO.Path.Combine(cojt.FullName, "TuneData.xml"))

       pmDocManager.SavePrototypeDataToDocument(cojt.FullName, data)

    Dim inserted As ITxComponent = TxApplication.ActiveDocument.PhysicalRoot.InsertComponent(

         New TxInsertComponentCreationData(IO.Path.GetFileNameWithoutExtension(cojt.FullName),

         cojt.FullName))

    insList.Add(inserted)

Next

component.Paste(insList)

For Each obj As ITxObject In insList

    obj.Delete()

Next

 

And now I try to create a pose for the equipment prototype:

 

Dim newDevice As TxDevice = joint.Device

Dim valuesV As New ArrayList

Dim valuesR As New ArrayList

valuesV.Add(CDbl(0))

valuesR.Add(CDbl(1))

 

Dim modelables As TxObjectList = component.GetAllDescendants(New TxTypeFilter(GetType(ITxKinematicsModellable)))

For Each modelable As ITxKinematicsModellable In modelables

    For Each poseJoint As TxJoint In modelable.Joints

        valuesV.Add(CDbl(0))

       Dim limits As ITxJointHardLimits = poseJoint.HardLimits

       If TypeOf limits IsNot TxJointConstantHardLimits Then

          valuesR.Add(CDbl(0))

       Else

          Dim hardLimits As TxJointConstantHardLimits = limits

          If hardLimits.UpperLimit = 0R Then

                     valuesR.Add(hardLimits.LowerLimit)

          Else

                     valuesR.Add(hardLimits.UpperLimit)

          End If

      End If

   Next

Next

newDevice.CreatePose(New TxPoseCreationData("V", New TxPoseData() With {.JointValues = valuesV}) With {.CreateAtInstance = False})

newDevice.CreatePose(New TxPoseCreationData("R", New TxPoseData() With {.JointValues = valuesR}) With {.CreateAtInstance = False})

 

After that I see in the poses editor for the equipment prototype two poses: R and V, but the poses values are set just for the joint j1, and all joints in the sub-components have value 0.

 

What is the right way to programmatically define poses for equipment prototype?

2 REPLIES

Re: How to define a pose for equipment prototype programatically?

Siemens Legend Siemens Legend
Siemens Legend

Hi,

 

What you can do is to update joint values directly to the equipment and the subdevices and then to get the CurrentPose of the equipment and use it for the pose data (TxPoseData):

 

TxPoseCreationData poseCreationData = new TxPoseCreationData("Pose", newDevice.CurrentPose);

 

Best Regards,

DianaG

Re: How to define a pose for equipment prototype programatically?

Valued Contributor
Valued Contributor
Hi,
Thank you!
Best Regards
ASE