Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help/ advice needed; getting absolute coordinates

Status
Not open for further replies.

MecaTron101

Automotive
Jun 30, 2014
7
SE
Hi
I am working on a macro for extracting the absolute coordingates for the points making up a polyline, and have been tinkering around with the existing functions at I am using the function for getting relative coordinates, and I have integrated the first code under the link so that I can define variables as the custom datatype iPct, so that part works. The problem comes when I try to get the coordintes using the measurable function. The macro stops at the highlighted point and gives the error message: "Compile error: ByRef argument type mismatch". I think there is something with the datatype that it doesn't like.
Has anyone else been able use these macros to get absolute coordinates and what kind of datatype did you use? Did you have to change the code?
I would greatly appreciate any help.


Code:
 'coordinate extraction process
    Dim TheSPAWorkbench As Workbench
    Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench") ' set TheSPAWorkbench
        Dim MeasurePoint, MeasureLength As reference
            Dim oRad As Length
                '**************************************************************************************************************************************
                    For i = 1 To polyline1NrOfElements       'iterate through all poinst of polyline
                    myPolyline.GetElement i, activePoint, oRad
                            
                        Set MeasureLength = TheSPAWorkbench.GetMeasurable(myPolyline)
                        myPolylineLength = MeasureLength.Length
                     
                    LCS axisSystem1, ([highlight #EF2929]activePoint[/highlight])
                    
                    If oRad Is Nothing Then RadiusAtPoint = False Else: RadiusAtPoint = True                ' check if Radius at point
                                       
                    'add point index
                    mytable.SetCellString 2 + i, 1, catPointIndex & i
        
                    xPoint = Round(Diff.X, 1) 'check 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        'check if integer
                            mytable.SetCellString 2 + i, 2, xPoint & ",0"       'add ",0"
                        Else
                            mytable.SetCellString 2 + i, 2, Round(Diff.X, 1)     'else, use 1 decimal
                        End If
                    
                    yPoint = Round(Diff.Y, 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(Diff.Y, 1)
                        End If
        
                    zPoint = Round(Diff.Z, 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(Diff.Z, 1)
                        End If
                                        
                    If RadiusAtPoint Then
                        radPoint = Round(oRad.Value, 1)     'same method as above
                            If radPoint = 0 Then
                                mytable.SetCellString 2 + i, 5, ""
                            ElseIf Int(radPoint) / radPoint = 1 Then
                                mytable.SetCellString 2 + i, 5, radPoint & ",0"
                            Else
                                mytable.SetCellString 2 + i, 5, Round(oRad.Value, 1)
                            End If
                    End If
                End if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top