×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Help/ advice needed; getting absolute coordinates

Help/ advice needed; getting absolute coordinates

Help/ advice needed; getting absolute coordinates

(OP)
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 http://www.eng-tips.com/faqs.cfm?fid=1824. 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 --> CATVBA

'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, (activePoint)
                    
                    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 




Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources