Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Matrix.Cell() gives me na error

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
p.serek
240 Views, 3 Replies

Matrix.Cell() gives me na error

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

Tags (3)
Labels (3)
3 REPLIES 3
Message 2 of 4
JMGunnar
in reply to: p.serek

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))
Message 3 of 4
Dev_rim
in reply to: p.serek

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
in reply to: Dev_rim

Hi Devrim,

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

Regards,
Przemek

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report