MecaTron101
Automotive
Hi!
I need som help with my macro code.
I'm working on a macro to create drawing tables with X, Y and Z coordinates for 3D points. So far I managed to get it working properly and it spits out nice tables, no problem there.
However, I want it to always extract coordinates relative to the absolute axis system. By default it picks the local axis, and that is fine as long as it's in the same position as the absolute, but if the local is moved the coordinates become inaccurate.
Below is a sample of my code. It uses a for loop to cycle the selected points and pick X, Y and Z. The code highlighted in green accesses Catia's measure function.
Is there a way select a specific axis system as point of origin? I've searched this forum but haven't been able to find anything that's been helpful to my problem.
If other users are interested in this type of macro I gladly post the whole code. I also have another macro that exports the same data to Excel.
Grateful for any help
I need som help with my macro code.
I'm working on a macro to create drawing tables with X, Y and Z coordinates for 3D points. So far I managed to get it working properly and it spits out nice tables, no problem there.
However, I want it to always extract coordinates relative to the absolute axis system. By default it picks the local axis, and that is fine as long as it's in the same position as the absolute, but if the local is moved the coordinates become inaccurate.
Below is a sample of my code. It uses a for loop to cycle the selected points and pick X, Y and Z. The code highlighted in green accesses Catia's measure function.
Is there a way select a specific axis system as point of origin? I've searched this forum but haven't been able to find anything that's been helpful to my problem.
If other users are interested in this type of macro I gladly post the whole code. I also have another macro that exports the same data to Excel.
Grateful for any help
Code:
[indent][/indent]'create the table itself
Set MyTable = myView.Tables.Add(100, 100, numberOfPoints + 2, 4, 7.5, 20)
'**********************************************************************************************************************************************
[highlight #8AE234]Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench") ' set TheSPAWorkbench[/highlight]
For i = 1 To numberOfPoints 'create correct number of rows
Set Element = selection1.Item(i)
Set selPoint = Element.Value
[highlight #8AE234]Set TheMeasurable = TheSPAWorkbench.GetMeasurable(selPoint)
TheMeasurable.GetPoint coords 'get coordinates from Measurable[/highlight]
MyTable.SetCellString 2 + i, 1, letter & i 'add point index
xPoint = Round(coords(0), 1) 'check if coordinate has decimals
If xPoint = 0 Then 'avoid division with zero
MyTable.SetCellString 2 + i, 2, "0,0" 'add 0,0
ElseIf Int(xPoint) / xPoint = 1 Then 'if integer
MyTable.SetCellString 2 + i, 2, xPoint & ",0" 'add ",0"
Else
MyTable.SetCellString 2 + i, 2, Round(coords(0), 1) 'else, use 1 decimal
End If
yPoint = Round(coords(1), 1) 'same procedure for y and z
If yPoint = 0 Then
MyTable.SetCellString 2 + i, 3, "0,0"
ElseIf Int(yPoint) / yPoint = 1 Then
MyTable.SetCellString 2 + i, 3, yPoint & ",0"
Else
MyTable.SetCellString 2 + i, 3, Round(coords(1), 1)
End If
zPoint = Round(coords(2), 1)
If zPoint = 0 Then
MyTable.SetCellString 2 + i, 4, "0,0"
ElseIf Int(zPoint) / zPoint = 1 Then
MyTable.SetCellString 2 + i, 4, zPoint & ",0"
Else
MyTable.SetCellString 2 + i, 4, Round(coords(2), 1)
End If
Next