GetRelated with Drawing views


I'm trying to use the GetRelated method to find out what view a dimension belongs to, I realise that I will probably have to do some recursion to get up to the view from the line I'm attached to.

My problem is that I am not getting any data returned, I can find out how many points the dim is related to but not what it is related to e.g. a line. If I Draw In View and attach a dimension to the same line the code returns the line object        

Code snippet below

seobject.GetRelated(0, graphicobj1, seX1, seY1, seZ1, seKeyPoint)

seobject.GetRelatedCount(secount)  ' This works and returns a value of 2 i.e. both keypoints

For i = 0 To secount




Is this just the API that is broken or am I doing something wrong?




Posted by: James Singleton
Post date: 8/22/2007 3:42:32 AM


RE: GetRelated with Drawing views

Forgot to mention VB.Net VS2005 but have also tried this in VB6

Thanks again


Posted by: James Singleton
Post date: 8/22/2007 3:44:50 AM

RE: GetRelated with Drawing views



Just a hunch but I'd suspect that you're Index value is what's killing you. Remeber that COM index's are 1 based and not 0 based. Try seobject.GetRelated(1,....)


Posted by: Jason Newell
Post date: 8/22/2007 12:19:12 PM

RE: GetRelated with Drawing views


Hi Jason, thanks for the reponse but thats not it.

Full VB6 code below,

To useSmiley Tonguelace a view in draftAdd dimensionSelect dimensionRun app - Gives count crashes on related itemsRight click on view and Draw in ViewAdd the same dimension againSelect dimensionRun app - Gives count and related item names

Private Sub Command1_Click()


    Dim objApp As Object

    Dim objSheet As Object

    Dim graphicobj As Object

    Dim objDim As Object

    Dim seCount As Long

    Dim seKeyPoint As Boolean

    Dim seX As Double, seY As Double, seZ As Double, i As Long


    'Get SE object

    Set objApp = GetObject(, "SolidEdge.Application")

    Set objDim = objApp.ActiveSelectSet(1)

    Call objDim.GetRelatedCount(seCount)

    MsgBox seCount & " related"

    For i = 0 To seCount - 1


        ' Get the related elements

        Call objDim.GetRelated(i, graphicobj, seX, seY, seZ, seKeyPoint)

        MsgBox "Item " & i & ": " & graphicobj.Name


    Next i

    Set graphicobj = Nothing

    Set objDim = Nothing

    Set objSheet = Nothing

    Set objApp = Nothing



End Sub

Thanks again 


Posted by: James Singleton
Post date: 8/22/2007 11:21:53 PM

RE: GetRelated with Drawing views



your code unfortunately still starts with index 0 in your for loop!




Posted by: Wolfgang Kunert
Post date: 8/24/2007 12:36:57 AM

RE: GetRelated with Drawing views

Sorry for not getting back to you guys sooner, I've been away and had not had chance to check back.

Wolfgang, The code above works perfectly, well as described above. If it was .NET then I would agree that it should be 1 based.


Does anyone have any other ideas why this does not return any objects when the dimension is attached to a line in a drawing view?





Posted by: James Singleton
Post date: 9/4/2007 11:00:07 AM