×
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

Array of points. Connection points between curves

Array of points. Connection points between curves

Array of points. Connection points between curves

(OP)
Hi everybody,

I'm still working on my CATIA script to create a body from some points coordinates I have in an Excel file. I found great information about scripts to perform this task, so it is going pretty well. However I still have a problem.

Here is the deal. I have curves which share some 'conection' points, as this vertices are belonging to 3 or 4 curves in some intersections. If I write the Excel file with all the points for each curve I guess it will result in some cases in to 3 or 4 'different' points at the same coordinates. How can I fix this problem?

My idea was to create a ConnectionPoints array where all this vertices are loaded. Then another matrix where each row is the curve I consider, and the columns are the beginning and ending conection point index. Something like this, considering I just have 4 vertices to build up a pyramid.

[1 2; 2 4; 2 3; 1 3; 3 4; 1 4]

Then, when I create the splines, first I add the start point, then I just read all the points but the extremes from the Excel file, and finally I add the end point. Please, find below the code. So, when I run it, it gives me an "Type Mismatch" error in the command

Spline(iSplineId).AddPoint ConnectionPoint(iStartPointId)    

I was expectig it to add the connection point with index iStartPointId in the spline, but it doesnt. I think it is because of ConnectionPoint(...) type. But I don't have any other idea about how to fix this problem without creating this ConnectionPoint array...

Any help or advice is welcome. Thanks in advance...

L3munoz.

Sub BuildingModel()
    Dim PtDoc As Object
    Dim PtPart As Object
    Dim PtHybridBody As Object
    Dim myPtHybridBody As Object

    Dim myPtSheet As Object

    Set PtDoc = GetCATIAPartDocument
    Set PtPart = PtDoc.Part
    Set PtHybridBody = PtPart.HybridBodies
    Set myPtHybridBody = PtHybridBody.Add
    myPtHybridBody.Name = "Train Geometry"

    Set myPtSheet = GetExcelFile    
    
    Dim iLinea As Integer
    Dim iValide As Integer
    Dim X As Double
    Dim Y As Double
    Dim Z As Double
    
    Dim ExtremePoints() As Integer
    Set ExtremePoints() = GeometryInfo
    
    Dim ConnectionPoint() As Object
    Dim Point As Object
    Dim Spline() As Object
    Dim iPointId As Integer
    Dim iSplineId As Integer

    Dim iStartPointId As Integer
    Dim iEndPointId As Integer
    
    iLinea = 1
    iValide = 0
    iPointId = 1
    iSplineId = 1

    While iValide<> ciEnd
        AnalyzeCell myPtSheet, iLinea, X, Y, Z, iValide
        iLinea = iLinea + 1
        
        If (iValide = 1) Then
            While iValide <> ciEndConnectionPoints
                AnalyzeCell myPtSheet, iLinea, X, Y, Z, iValide
                iLinea = iLinea + 1
                ReDim ConnectionPoint(1 to iPointId) As Object
                Set ConnectionPoint(iPointId) = PtPart.HybridShapeFactory.AddNewPointCoord(X, Y, Z)
                myPtHybridBody.AppendHybridShape ConnectionPoint(iPointId)
                iPointId = iPointId + 1
            Wend    
        End If

        If (iValide = 2) Then
            ReDim Spline(1 to iSplineId) As Object    
            Set Spline(iSplineId) = PtPart.HybridShapeFactory.AddNewSpline
            Spline(iSplineId).SetSplineType 0
            Spline(iSplineId).SetClosing 0
            
            iStartPointId = ExtremePoints(iSplineId,1)
            iEndPointId = ExtremePoints(iSplineId,2)
            Spline(iSplineId).AddPoint ConnectionPoint(iStartPointId)        

            While iValide <> ciEndCurve
                AnalyzeCell myPtSheet, iLinea, X, Y, Z, iValide
                iLinea = iLinea + 1

                If (iValide = 0) Then
                    Set Point = PtPart.HybridShapeFactory.AddNewPointCoord(X, Y, Z)
                    myPtHybridBody.AppendHybridShape Point
                    Spline(iSplineId).AddPoint Point
                End If
            Wend
        
            Spline(iSplineId).AddPoint ConnectionPoint(iEndPointId)

            myPtHybridBody.AppendHybridShape Spline(iSplineId)
            iSplineId = iSplineId + 1
        End If
        
        PtPart.Update
    Wend            
End Sub

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