Retreive Part Information from drawing view line/Curve segment

Retreive Part Information from drawing view line/Curve segment

3DAli
Collaborator Collaborator
919 Views
7 Replies
Message 1 of 8

Retreive Part Information from drawing view line/Curve segment

3DAli
Collaborator
Collaborator

Hi there, 

 

I am trying to see if there is a way to get the reference document info such as display name, by selecting a drawing curve segment. and I am wondering if there is a way, what it would return in case of a line that is part of a weld bead.

 

Dim oDoc As DrawingDocument
Dim oView As DrawingView

Set oDoc = ThisApplication.ActiveDocument
Set oView = oDoc.Sheets.Item(1).DrawingViews.Item(1)

Dim oLine As DrawingCurve

Set oLine = oView.DrawingCurves.Item(1)

Dim RefDoc As ReferenceComponent

Call ThisApplication.ActiveDocument.SelectSet.Select(oLine.Segments.Item(1))
MsgBox "Drawing View : " & oView.Name, vbInformation
MsgBox "Line : " & , vbInformation

 

here is the code, simple , however I cant seem to be able to find a method to the any info on the referenced compomnent for that selected  segment.

 

any help would be greatly appreciated.

 

Best,

Ali

0 Likes
Accepted solutions (1)
920 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

Hi @3DAli.  Here is an example like that you might like.  Take a look at this, and see if it helps you reach your goal.  There is one main variable involved, called ModelGeometry.  It is defined as a generic Object, because it could represent multiple types of objects.  That is where you will need to determine what type of object it represents and go from there.  It is usually either an Edge or EdgeProxy type object though.

Sub PickDrawingCurveShowItsData()
    Dim oDCS As DrawingCurveSegment
    Set oDCS = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Pick Drawing View Curve Segment")
    If oDCS Is Nothing Then Exit Sub
    Dim oDC As DrawingCurve
    Set oDC = oDCS.Parent
    Dim oView As DrawingView
    Set oView = oDC.Parent
    Dim oMG As Object
    Set oMG = oDC.ModelGeometry
    Call MsgBox("DrawingCurve.ModelGeometry Type = " & TypeName(oMG), vbInformation, "ModelGeometry Type Name")
    If TypeOf oMG Is Edge Then
        Dim oEdge As Edge
        Set oEdge = oMG
        Dim oBody As SurfaceBody
        Set oBody = oEdge.Parent
        Dim oCD As ComponentDefinition
        Set oCD = oBody.ComponentDefinition
        Dim oModelDoc As Document
        Set oModelDoc = oCD.Document
        Call MsgBox("Crossed over to 'model' side, and climbed ladder to model document.", vbInformation, "")
    End If
End Sub

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 8

WCrihfield
Mentor
Mentor

Also if your view is showing an assembly, any Edge type object you may get will definitely be an EdgeProxy type, instead of a regular Edge, but since EdgeProxy type is derived from the Edge type, both types will be compatible with the Edge type variable.  Then the edge's parent SurfaceBody may be the weld bead.  Then that weld bead will actually be within what is called a WeldsComponentDefinition (encapsulates the welds in a weldment type assembly, similar to how the SheetMetalComponentDefinition encapsulates the FlatPattern and some feature types in a Part).  Then that WeldsComponentDefinition will be within a WeldmentComponentDefinition, which will be within an AssemblyDocument whose SubType has been set to that of a weldment.  Just some additional info to help you along the exploration path.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 8

3DAli
Collaborator
Collaborator

@WCrihfield , Thanks so much , this is a great starting point for sure, ultimately my goal is to be able to cycle through all the visible edges in a given drawing view and filter out those that belong to a weld bead and then from there, you can automate lets say a series of things such as color , or assigning a setch symbol to , etc etc. 

I will explore this more in depth and reach out if I hit any bump on the road to share thoughts and brainstorm here together.

 

Cheers

Ali

0 Likes
Message 5 of 8

WCrihfield
Mentor
Mentor

OK.  Just thinking through the keyboard here, but I'm thinking it may be more work approaching this task from ths side of trying to cycle through each DrawingCurve (and/or DrawingCurveSegment) in the DrawingView.DrawingCurves (a DrawingCurvesEnumerator), and trying to check if each one may belong to a weld bead.  It may be more logical or more efficient to start with the main 'model' document of the view (DrawingView.ReferencedDocumentDescriptor.ReferencedDocument), then navigate through that model structure that way to get to the welds that way first...then use the DrawingView.DrawingCurves(oInputModelObject) to get the DrawingCurvesEnumerator representing the DrawingCurves in that view for that model object.  In a case like this, I am thinking that you may be able to use the ComponentOccurrence object that represents the WeldsComponentDefinition within the WeldmentComponentDefinition.ComponentOccurrences collection, as input into the DrawingView.DrawingCurves property.  Just some thoughts.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 8

3DAli
Collaborator
Collaborator

Point taken, makes total sense even programatically since you narrow down the starting points quite a bit, thanks for the advice.

Best,

Ali

0 Likes
Message 7 of 8

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

I don't think you can go the other way round as Weld Beads are not supported by the API - here is how you can check: https://adndevblog.typepad.com/manufacturing/2015/05/is-this-object-supported-by-the-api.html

 

But I think  answered your question: "that weld bead will actually be within what is called a WeldsComponentDefinition" - or did you run into a scenario where that did not work?

' Select a curve in the drawing view and run the below code
Sub WeldTest()
  Dim dcs As DrawingCurveSegment
  Set dcs = ThisApplication.ActiveDocument.SelectSet(1)

  If TypeOf dcs.Parent.ModelGeometry.ContainingOccurrence.Definition Is WeldsComponentDefinition Then
    Call MsgBox("It's a weld")
  Else
    Call MsgBox("It's not a weld")
  End If
End Sub

 



Adam Nagy
Autodesk Platform Services
0 Likes
Message 8 of 8

3DAli
Collaborator
Collaborator

@adam.nagy thanks so much , this works as expected