Cant add a work point to specific part/parts

Cant add a work point to specific part/parts

davidt162003
Advocate Advocate
387 Views
2 Replies
Message 1 of 3

Cant add a work point to specific part/parts

davidt162003
Advocate
Advocate

so i have a series of parametric parts which i then update using the api and within that update i add a work point on to them typically using this code 

However as seen in the screen shot its starting throwing a error for just a single type part.

 

Capture.PNG

 this is the part in question.  

If i had to guess the error either occurs because I'm trying to add in the work point before the update is complete(parameters changed but model isn't updated) or because of something to do with the base part file I'm copying it from.  

HII
0 Likes
Accepted solutions (1)
388 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @davidt162003.  You did not post the code that you were trying to use for this task, and did not attach the part file itself for us to test on, so it would be very difficult for us to help determine why that code is having trouble doing its task on that one specific part.  Nothing about the image seems to show any reason for the problem.  Is it possible that the part is ReadOnly, for one reason or another?  If the part was from the Content Center, or its file is located in an area designated as a Library, those could cause the part to act like ReadOnly.  Also, if accessing that part from an assembly, and it had multiple ModelStates in it, and there were more than one of them in the assembly, it may be understanding that assembly component as being a 'member' ModelState, which could be treated as ReadOnly.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

davidt162003
Advocate
Advocate
Accepted solution

ah sorry i had attached the code it must have been removed when i posted it. This is the code which creates the work point.

 Friend Function AddWPsByCords(XCord As Double, YCord As Double, ZCord As Double,
                                 Name As String, PartDef As PartComponentDefinition,
                                  _App As Inventor.Application)
     Dim WPList = PartDef.WorkPoints
     Dim TGPnt = GetiPoint3D(XCord, YCord, ZCord, _App)
     For Each WpCheck As WorkPoint In WPList
         If WpCheck.Name = Name Then
             If WpCheck.Point.X = XCord And WpCheck.Point.Y = YCord And WpCheck.Point.Z = ZCord Then
                 Return WpCheck
             Else
                 WpCheck.Delete()
                 ' WpCheck.SetByPoint(TGPnt)

             End If
         End If
     Next
     Dim Wps = PartDef.WorkPoints.AddFixed(TGPnt)
     Wps.Name = Name
     Return Wps
 End Function

and this is the code which updates the model and places the work point

        Friend Sub UpdatePreBuiltForgedBody(Geometry As InventorHeader_Geometry)
            With Geometry
                UpdateParameterValue("WallThickness", .WallThc, MyPartDef)
                UpdateParameterValue("OuterRadius", .OutRad, MyPartDef)
                UpdateParameterValue("HeaderLength", .HeaderLength, MyPartDef)
 'Previusly the code to add the work point was here
                UpdateParameterValue("BeltOuterRadius", .BeltOutRad, MyPartDef)
                UpdateParameterValue("BeltLength", .BeltLength, MyPartDef)
                UpdateParameterValue("NozzleOD", .ForgedNozzleOD, MyPartDef)
                UpdateParameterValue("NozzleID", .ForgedNozzleID, MyPartDef)
                UpdateParameterValue("NozzleStandout", .NozzleStandout, MyPartDef)
                UpdateParameterValue("OuterFilletRadius", .OuterFilletRadius, MyPartDef)
                UpdateParameterValue("InnerFilletRadius", .InnerFilletRadius, MyPartDef)
                AddWPsByCords(0, .OutRad, .HeaderLength / 4, "BalloonPoint", MyPartDef, Driver._App)
                ''TODO:Sort out the weld points for this 
                CreateWeldPoints()
            End With
        End Sub

Ive fixed it now by moving where its called. I beleive what was happening was that becasue the parameter changes were incomplete, invalid geometry was created. then by trying to place that work point it was trying to force the model to update which caused the error 

HII
0 Likes