CreateTransform(null) was working until Solidworks API 2017 and giving a default transform object.
Now in Solidworks API 2018, CreateTransform(null) returns null.
How do I create a default / identity transform using SolidWorks API 2018??
I don't see anywhere in the documentation that you should expect any return from CreateTransform(null). If it used to work, but now it doesn't, you may want to contact api support. If they decide it should work, and they fix it, they need to update the documentation.
In the meantime, you will need to build your own 16 member ArrayDataIn and pass that to CreateTransform.
I have used this in the past. All zeros works just fine due to this line in the documentation:
If any axis is 0, or any two axes are parallel, or all axes are coplanar, then an identity matrix replaces the rotational sub-matrix
Dim aXformArray(15) As Double
For i = 0 To 15 aXformArray(i) = 0 Next i Set CsysXform = myUtil.CreateTransform(aXformArray) 'Using 0 for all elements should create a unity matrix
I agree with Josh: CreateTransform(null) shouldn't return anything.
Although the documentation does mention "If any axis is 0, [...] then an identity matrix replaces the rotational sub-matrix."
But I think that's bad practice to use it.
Anyway for identity transform use:
Dim Xform(15) As Double Dim vXform As Variant Xform(0) = 1# Xform(1) = 0# Xform(2) = 0# Xform(3) = 0# Xform(4) = 1# Xform(5) = 0# Xform(6) = 0# Xform(7) = 0# Xform(8) = 1# Xform(9) = 0# Xform(10) = 0# Xform(11) = 0# Xform(12) = 1# Xform(13) = 0# Xform(14) = 0# Xform(15) = 0# vXform = XformSet MathXform = MathUtility.CreateTransform(vXform)
Thank you for your responses.
CreateTransform(null) used to create this unit transform.
see this example
I need to contact API support and check what they say.
Guess what.. I searched the API Support Knowledge Base and it is a bug
we will get it only in 2020
Hepzibah Chandranand wrote: Thank you for your responses. CreateTransform(null) used to create this unit transform.see this examplehttp://help.solidworks.com/2015/english/api/sldworksapi/Align_Assembly_Component_to_Assembly_Origin_and_Planes_Example_VB.htm?verRedirect=1 I need to contact API support and check what they say.
Hepzibah Chandranand wrote:
Don't bother contacting API support.
1. If the problem were 2018, it's already too late. SP5 is out, they aren't going to change anything about 2018, so you would need to just use the suggestions above.
2. Your problem is likely somewhere else. I have 2018 SP5. I just did this:
Retrieving data ...