Changing the name of workpoints based on a part parameter

Changing the name of workpoints based on a part parameter

matthew_neesley
Collaborator Collaborator
607 Views
7 Replies
Message 1 of 8

Changing the name of workpoints based on a part parameter

matthew_neesley
Collaborator
Collaborator

I have parts that have workpoints in them for extraction to an Excel file.  I just realized today that it would be super helpful to change the name of the workpoints based on the other parameters of the part.  This way, in one specific part config, only the specific workpoints I want would actually be exported (the Macro I'm using asks for "include this string in your search").  So I figure if I don't want them exported, when Parameter 1 changes from Left to right, Workpoint1 would be renamed to some nonsensical term.  

Is my overall thinking for this the best way to accomplish what I need?  If so...

 

After having done some research...do Workpoint names in the tree function as "browser nodes"?

 

0 Likes
608 Views
7 Replies
Replies (7)
Message 2 of 8

Sergio.D.Suárez
Mentor
Mentor

Hi, I think it should be clearer in your explanation. It should establish a criterion to identify which point it should export and which point it should not. based on that rule the names of the work points would be changed.


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support

@matthew_neesley,

 

do Workpoint names in the tree function as "browser nodes"? - Yes

 

Are you trying to rename workpoints as per multivalue parameter in the same part document or different?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 8

matthew_neesley
Collaborator
Collaborator

Thanks for the response!  More specifics:

 

I have factory conveyor beds (.ipt's) that curve to the left or right.  They have control cards on the outside edge.  We've been using one multi-value asset for both...so when the direction of travel changes, the side that the leg connector is on changes. I'm using workpoints located at each connector for export with a Macro to a .csv file...but hiding the workpoint's visibility still results in it being exported by the Macro (which searches by name).  If the conveyor bed curves to the right, I need the workpoint representing the corresponding LEFT-travel leg connector to change name to a nonsense name in the tree so it does NOT get picked up by the selection Macro.  

 

If I can make this work then I can still retain having one asset for both left AND right-hand travel; otherwise I'll need two separate assets, one for right-hand curve-direction and one for left-hand.  Make sense?

0 Likes
Message 5 of 8

Sergio.D.Suárez
Mentor
Mentor

...but hiding the workpoint's visibility still results in it being exported by the Macro (which searches by name). 
Hi, excuse me. From what you have written, it is assumed that if the point is hidden, you do not want it to be exported. Surely it has a condition to search by name as you say, you could add to that condition an "AndAlso" and specify that it must also be fulfilled that the point is visible, if it is not exported. regards

Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 6 of 8

matthew_neesley
Collaborator
Collaborator

Oooh!  Duh.  Hadn't thought of that Smiley Very Happy  Will definitely look into that.  Thanks!

0 Likes
Message 7 of 8

Sergio.D.Suárez
Mentor
Mentor

This is a code that takes from
https://modthemachine.typepad.com/my_weblog/2011/06/writing-work-points-to-an-excel-file.html
modified a bit, with only add the lines marked in red, jump to the point of work that is hidden.

Public Sub ExportWorkPoints()
    ' Get the active part document.
    Dim partDoc As PartDocument
    If ThisApplication.ActiveDocumentType = kPartDocumentObject Then
        Set partDoc = ThisApplication.ActiveDocument
    Else
        MsgBox "A part must be active."
        Exit Sub
    End If
    
    Dim partDef As PartComponentDefinition
    Set partDef = partDoc.ComponentDefinition
    
    ' Get the filename to write to.
    Dim dialog As FileDialog
    Dim filename As String
    Call ThisApplication.CreateFileDialog(dialog)
    With dialog
        .DialogTitle = "Specify Output .CSV File"
        .Filter = "Comma delimited file (*.csv)|*.csv"
        .FilterIndex = 0
        .OptionsEnabled = False
        .MultiSelectEnabled = False
        .ShowSave
        filename = .filename
    End With
    
    If filename <> "" Then
        ' Write the work point coordinates out to a csv file.
        On Error Resume Next
        Open filename For Output As #1
        If Err.Number <> 0 Then
            MsgBox "Unable to open the specified file. " & _
                   "It may be open by another process."
            Exit Sub
        End If
        
        ' Get a reference to the object to do unit conversions.
        Dim uom As UnitsOfMeasure
        Set uom = partDoc.UnitsOfMeasure
        
        ' Write the points
        
        Dim i As Integer
        For i = 1 To partDef.WorkPoints.Count
        
            If partDef.WorkPoints.Item(i).Visible = True Then

                Dim xCoord As Double
                xCoord = uom.ConvertUnits(partDef.WorkPoints.Item(i).Point.X, _
                     kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
                         
                Dim yCoord As String
                yCoord = uom.ConvertUnits(partDef.WorkPoints.Item(i).Point.Y, _
                     kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
                         
                Dim zCoord As String
                zCoord = uom.ConvertUnits(partDef.WorkPoints.Item(i).Point.Z, _
                     kCentimeterLengthUnits, kDefaultDisplayLengthUnits)
                         
                Print #1, partDef.WorkPoints.Item(i).Name & "," & _
                    Format(xCoord, "0.00000000") & "," & _
                    Format(yCoord, "0.00000000") & "," & _
                    Format(zCoord, "0.00000000")
            End If
        Next
        
        Close #1
        
        MsgBox "Finished writing data to """ & filename & """"
    End If
End Sub

I hope it will help you to give a path so that you can solve your problem. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 8 of 8

matthew_neesley
Collaborator
Collaborator

very cool, I see exactly what you did there! I will try it out in the next 24 hrs.  Thanks!

0 Likes