Matrix.Cell() gives me na error

Matrix.Cell() gives me na error

p.serek
Contributor Contributor
514 Views
3 Replies
Message 1 of 4

Matrix.Cell() gives me na error

p.serek
Contributor
Contributor

Hello everyone,

 

I've got a question about my code snippet. It's just copied from developer reference:

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim dPi As Double
dPi = Atan(1) * 4
    
' Define the origin point.
Dim oOrigin As Point
oOrigin = oTG.CreatePoint(10, 5, 0)
    
' Define the axis vectors.  Pi/4 is 45 degrees in radians.
Dim oXAxis As UnitVector
Dim oYAxis As UnitVector
Dim oZAxis As UnitVector
oXAxis = oTG.CreateUnitVector(Cos(dPi / 4), Sin(dPi / 4), 0)
oYAxis = oTG.CreateUnitVector(-Cos(dPi / 4), Sin(dPi / 4), 0)
oZAxis = oTG.CreateUnitVector(0, 0, 1)
    
' Create the matrix and define the desired coordinate system.
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix
oMatrix.SetCoordinateSystem(oOrigin, oXAxis.AsVector, oYAxis.AsVector, oZAxis.AsVector)

Dim dd = oMatrix.Cell(0, 0)

 

But when I call Matrix.Cell(0, 0) I get an error:

pserek_0-1679984749643.png

 

Same thing when I call this code by C#. It doesn't work in Inv 2022 and 2023 (other not tested yet).

 

Am I doing something wrong or is there a bug regarding the Cell property of Matrix?

 

I've read documentation and it says:

Matrix.Cell( Row As Long, Col As Long ) As Double

 

So it looks like my code is correct.

 

Please help.

 

Regards,

Przemek

0 Likes
Accepted solutions (1)
515 Views
3 Replies
Replies (3)
Message 2 of 4

JMGunnar
Collaborator
Collaborator

Check Matrix 

 

Best Regards Johan @p.serek 

 

Dim dCells(15) As Double
		oMatrix.GetMatrixData(dCells)

		Dim Pos = ThisDoc.Geometry.Matrix(oMatrix.Cell(1, 1), oMatrix.Cell(1, 2), oMatrix.Cell(1, 3), oMatrix.Cell(1, 4),
		oMatrix.Cell(2, 1), oMatrix.Cell(2, 2), oMatrix.Cell(2, 3), oMatrix.Cell(2, 4),
		oMatrix.Cell(3, 1), oMatrix.Cell(3, 2), oMatrix.Cell(3, 3), oMatrix.Cell(3, 4),
		oMatrix.Cell(4, 1), oMatrix.Cell(4, 2), oMatrix.Cell(4, 3), oMatrix.Cell(4, 4))
0 Likes
Message 3 of 4

Dev_rim
Advocate
Advocate
Accepted solution
Hi Przemek,
Cells indexes starts from 1, not 0. So first rows index will be 1 and the firs columns index will be 1.
Changing last line like this:
Dim dd = oMatrix.Cell(1, 1)
Will be enough probably.

Best Regards
Devrim
If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
Message 4 of 4

p.serek
Contributor
Contributor
Hi Devrim,

That helped, thanks a lot! I didn't think about it...

Regards,
Przemek