How to bubble sub assembly parts, and working with Assembly in general , Vb.net

How to bubble sub assembly parts, and working with Assembly in general , Vb.net

davidt162003
Advocate Advocate
238 Views
2 Replies
Message 1 of 3

How to bubble sub assembly parts, and working with Assembly in general , Vb.net

davidt162003
Advocate
Advocate

so ive just implemented sub assemblies into my project and their proving quite difficult, primary because alot of my functions were originally just listed for the part document object ive been able to sort alot of it but im still struggling how to get the representative draw curves on a drawing view of the assembly. ideally i want to include it in the block below. the component list comes from a function which gets all the components which have their origin within a transient box. 

the component list dose end up giving me all the component occurrences in the box but its the component occurrence object from the sub assembly rather than the one in the top level. 

 

 

   For Each pOcc As ComponentOccurrence In ComponentList
       Try
           Dim drawcurves As DrawingCurvesEnumerator
           drawcurves = ViewToBallon.DrawingCurves(pOcc)
           drawcurves = ViewToBallon.DrawingCurves(pOcc)
           Dim DrawCurve = drawcurves(1)
           Dim midpnt As Point2d
           midpnt = TryCast(DrawCurve.CenterPoint, Point2d)
           If midpnt Is Nothing Then midpnt = TryCast(DrawCurve.MidPoint, Point2d)
           If midpnt Is Nothing Then midpnt = GetiPoint2D(0, 0, _App)
           Dim PointCollection As ObjectCollection = _App.TransientObjects.CreateObjectCollection
           PointCollection.Add(midpnt)
           PointCollection.Add(Sheet.CreateGeometryIntent(DrawCurve))
           Dim Balloon = Sheet.Balloons.Add(PointCollection)
           Dim BalloonVal = Split(pOcc.Name, ":").First
           Balloon.BalloonValueSets(1).Value = BalloonVal
           PlaceBalloonArrow(Balloon, pOcc, ViewToBallon)
           BalloonList.Add(Balloon)
       Catch ex As Exception
       End Try
   Next

 

 

another question i have is regarding a method to make a interface/object or some other method which automatically reduces to the correct component definition. and more generally how others deal with sub assemblies 

 

HII
0 Likes
239 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Hi @davidt162003 

Can you share some images of what your looking to achieve? Is the BOM set to structured all levels and are the partslist rows exposed so the sub assembly and parts are visible? 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

davidt162003
Advocate
Advocate

I manged to fix my problem by using creating a custom list of component occurrences/ component occurrence proxies then overriding the value. But no originally i dont think i did have the BOM set to all levels. And i think originally i might not  have had the part only bom enabled 

 <Extension> Friend Function IncludingSubOccurences(AssemblyDef As AssemblyComponentDefinition, Optional ReturnedList As List(Of ComponentOccurrence) = Nothing)
     Dim FullList As New List(Of ComponentOccurrence) ' Proxy version is derived from componentoccurence both the object and literal sense
     For Each pOcc As ComponentOccurrence In AssemblyDef.Occurrences
         If pOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
             Dim pSubAssyDef As AssemblyComponentDefinition = pOcc.Definition
             For Each pSubOcc As ComponentOccurrence In pSubAssyDef.Occurrences
                 Dim pOccProxy As ComponentOccurrenceProxy = Nothing
                 pOcc.CreateGeometryProxy(pSubOcc, pOccProxy)
                 FullList.Add(pOccProxy)
             Next
         Else
             FullList.Add(pOcc)
         End If
     Next
     Return FullList
 End Function

 But in the end i used this, i would like to make it recursive but for my use i probably dont need to.

Then when i actually make these balloons i use this.

For Each pOcc As ComponentOccurrence In ComponentList
    Dim drawcurves As DrawingCurvesEnumerator

    Try

        'drawcurves = ViewToBallon.DrawingCurves(pOcc)

        drawcurves = ViewToBallon.DrawingCurves(pOcc)
        Dim DrawCurve = drawcurves(1)
        Dim midpnt As Point2d
        midpnt = TryCast(DrawCurve.CenterPoint, Point2d)
        If midpnt Is Nothing Then midpnt = TryCast(DrawCurve.MidPoint, Point2d)
        If midpnt Is Nothing Then midpnt = GetiPoint2D(0, 0, _App)
        Dim PointCollection As ObjectCollection = _App.TransientObjects.CreateObjectCollection
        PointCollection.Add(midpnt)
        PointCollection.Add(Sheet.CreateGeometryIntent(DrawCurve))
        Dim Balloon = Sheet.Balloons.Add(PointCollection)
        Dim BalloonVal = Split(pOcc.Name, ":").First
        Balloon.BalloonValueSets(1).OverrideValue = BalloonVal
        PlaceBalloonArrow(Balloon, pOcc, ViewToBallon)
        BalloonList.Add(Balloon)
    Catch ex As Exception
    End Try
Next

there might be a slightly better way 

 

HII
0 Likes