Need Assistance with gathering Workpoints from an Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
For starters, here's the code:
Private Function FindPoints(oView As DrawingView, dimPoint As String) Dim oAssyDoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument Dim occ As Object Dim oDef As Document = Nothing For Each oOcc As ComponentOccurrence In oAssyDoc.ComponentDefinition.Occurrences oDef = oOcc.Definition.Document For Each oWorkpoint As WorkPoint In oDef.ComponentDefinition.WorkPoints If oWorkpoint.Name = dimPoint Then occ = oOcc End If Next Next Return occ End Function
Essentially, oView is pointing to a targeted Section View (it's created this way so I could use the same code to target other drawing views if I need), and dimPoint is passing off the name of a Workpoint in the Assembly to try and target. I'm iterating through a list of names by calling this function in a FOR loop:
Dim wpNames As New List(Of String) From {"WP_1", "WP_1-1", "WP_1-2", "WP_2", "WP_2-1", "WP_3", "WP_4" } Dim oOcc(wpNames.Count - 1) As Object For i As Integer = 1 To wpNames.Count oOcc(i-1) = FindPoints(iView, wpNames(i)) Next i
The FindPoints code is supposed to reference the assembly used in my Section View, iterate through all of the workpoints listed in the referenced assembly, and if it matches up to my provided name (dimPoint), return the Workpoint so I can collected in my oOcc variable. This variable will be used to create dimensions down the road...however I can't get the iLogic code working correctly.
Here are my issues:
- The FOR Loop in my FindPoints function is not collecting any of my workpoints. It collects 1 object called Center Point, however, the name doesn't match up to the name of the Center Point that I'm using in my assembly.
- How do I correctly collect all of my WorkPoints from the Assembly so that I can iterate through them?
- DimPoint should pass the String "WP_1" from the wpNames List, but it adds a "-1" behind it. I checked this during debugging and found that prior to calling the FindPoints function, wpNames(0) returns the name "WP_1" correctly, but when checked inside the FindPoints function (i.e. directly after it's called), dimPoint returns "WP_1-1". Any ideas as to why?