Showing results for 
Search instead for 
Do you mean 
Reply

CreateJoint (ITxKinematicsModellable) PS12.1.3

Hi,

I want to use the new function "CreateJoint" from "ITxKinematicsModellable" from the PS Version 12.1.3.

 

In the Help Use is described below:

Dim instance As ITxKinematicsModellable

Dim creationData As TxJointCreationData

Dim value as Txjoint

 

value = instance.CreateJoint(creationData)

 

My Questions is:

I must assign a Value for the instance variable.

What type should I assign the variable instance?

 

I Test TxDevice, TxComponent and so on....

And I get an TxJointCreationFailedException.

 

 

7 REPLIES

Re: CreateJoint (ITxKinematicsModellable) PS12.1.3

[ Edited ]

Your instance must implement the ITxKinematicsModellable interface.

As TxDevice and TxComponent are implementing it, you should be fine.

 

My guess is, that your TxJointCreationData is lacking some parameter...

 

Re: CreateJoint (ITxKinematicsModellable) PS12.1.3

Hallo!

Can you help me with my code?

I don`t see any mistake in the TxJointCreationData or some Missing Paramter?

Thank you for your Help.

 

My Code:

Dim L_group As TxObjectList = l_Cto.GetAllDescendants(New TxTypeFilter(GetType(TxKinematicLink)))

Dim NewJoint As TxJoint

Dim fix As TxKinematicLink

Dim mobil As TxKinematicLink

Dim jointname As String = "J1_TEST"

Dim jtype as TxJoint.TxJointType

 

jtype = TxJoint.TxJointType.Revolute

fix = TryCast(L_group.Item(0), TxKinematicLink)

mobil = TryCast(L_group.Item(1), TxKinematicLink)

Dim testdata as New TxJointCreationData(jointname, jtype, fix, mobil)

Dim Joint as ITxKinematicsModellable

joint = TryCast(NeuesElement, TxDevice)

NewJoint = joint.CreateJoint(testdata)

 

Re: CreateJoint (ITxKinematicsModellable) PS12.1.3

[ Edited ]

hm...did you send the whole code?

Actually I never tried making a joint via API, but definitly a joint without axis-vectors can't work.

After defining your creationdata, I believe it has at least to look like this:

Dim testdata As New TxJointCreationData(jointname, jtype, fix, mobil)

testdata.SetAxisPoints(New TxVector(0, 0, 0), New TxVector(0, 0, 100))

 

Re: CreateJoint (ITxKinematicsModellable) PS12.1.3

I have already tried it with txvector.

I do it like this:

 

dim vector1 as txvector

dim vector2 as txvector

vector1 = New TxVector(0, 0, 0)

vector2 = New TxVector(0, 0, 100)

testdata.SetAxisPoints(vector1,vector2)

 

But i get also a error message with txvector.

Re: CreateJoint (ITxKinematicsModellable) PS12.1.3

I'm sorry, but it's hard to discuss only snippets.

Can't you post your complete code for generating the joint?

 

"Object reference not set..." is not an exception of the API.

Do you know how to use the debugger with PS?

It would tell you which object...

Re: CreateJoint (ITxKinematicsModellable) PS12.1.3

Here is my complete Code for generating the joint:

 

Dim d As New TxObjectList

d = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(New TxTypeFilter(GetType(TxDevice)))

NeuesElement = d.Item(d.Count - 1)

NeuesElement.Name = r.Name

 

'NEUES ELEMENT INS MODELLING

Dim MyComp As ITxObject = NeuesElement

MyCommandParameter.Object = MyComp

TxApplication.CommandsManager.ExecuteCommand("Modeling.SetModelingWorkingSpace", MyCommandParameter)

 

'KINEMATIKLINKS + JOINT AUF DREHACHSE VERSCHIEBEN

Dim l_Cto As TxDevice = TryCast(NeuesElement, TxDevice)

Dim l_von As TxComponent = TryCast(r, TxComponent)

Dim L_group As TxObjectList = l_Cto.GetAllDescendants(New TxTypeFilter(GetType(TxKinematicLink)))

Dim l_ctogroup As TxKinematicLink

For z = 0 To L_group.Count - 1

l_ctogroup = TryCast(L_group.Item(z), TxKinematicLink)

'TEST

Dim joint_new As TxJoint

Dim fix As TxKinematicLink

Dim mobil As TxKinematicLink

Dim namej As String = "TEST_J1"

Dim jtype As TxJoint.TxJointType

jtype = TxJoint.TxJointType.Revolute

fix = TryCast(L_group.Item(0), TxKinematicLink)

mobil = TryCast(L_group.Item(1), TxKinematicLink)

Dim test As New TxJointCreationData(namej, jtype, fix, mobil)

Try

test.SetAxisPoints(New TxVector(0, 0, 0), New TxVector(0, 0, 100))

Catch ex As Exception

MsgBox(ex.ToString)

End Try

Dim joint As TxDevice = NeuesElement

Try

joint_new = joint.CreateJoint(test)

Catch ex As Exception

MsgBox(ex.ToString)

End Try

'TEST ENDE

Re: CreateJoint (ITxKinematicsModellable) PS12.1.3

[ Edited ]

I tried it myself.

Sry that I did not correct your example, it's just a lot easier this way.

It's also for me the first API-kinematics ;-)

 

Dim objComp As TxComponent = TxApplication.ActiveDocument.PhysicalRoot.CreateLocalComponent(New TxLocalComponentCreationData("testobj"))

Dim objFixLink As TxKinematicLink = objComp.CreateLink(New TxKinematicLinkCreationData("fix"))

Dim objMoveLink As TxKinematicLink = objComp.CreateLink(New TxKinematicLinkCreationData("move"))

Dim objJoint As TxJoint = objComp.CreateJoint(New TxJointCreationData("TEST_J1", TxJoint.TxJointType.Revolute, objFixLink, objMoveLink))

objJoint.Axis = New TxJointAxis(New TxVector(0, 0, 0), New TxVector(0, 0, 100))