What's new

Session Type Issue

eneyer

Member
Session Type Issue

I've come across a peculiar issue...

When I load an assembly using the Hook.OpenFile() method, the Session.SessionType == ADObjectSubType.AD_ASSEMBLY

When I Get the Hook object and get the same session using the Hook.Sessions property, the
Session.SessionType == ADObjectSubType.AD_PART

It looks like the session IS in fact a PartSession because my code continues to work as though it was a part. The part was the first part in the model.
 

shubhab

Member


I tried this and I am correctly getting the SessionType for an assembly as 2, i.e. AD_ASSEMBLY.

Would you mind posting your code snippet here so I can see what is going wrong.

Here is the code snippet for what I am doing:

Set objSession = rootObj.OpenFile(CommonDialog1.FileName)

If objSession.SessionType = 2 Then
Label1.Caption = "Session Type of " & objSession.Name & " is: AD_ASSEMBLY"
End If

If I open an assembly, I am correctly getting the ADObjectSubType as 2 for an assembly.

Thanks,
Shubha,
Alibre, Inc.
 

eneyer

Member


I'm at home now, so I'll do my best with syntax...

adSession = objHook.Sessions.Item(lastindex) ' Getting a current session
adSession.SessionType somehow THEN = 1 (part session)

When I open the file like you did, it DOES work fine. When I get a currently openned session, it does not.
 

shubhab

Member


Eric,

I can now understand what you are seeing.
If an assembly has 2 parts in it (as occurrences), and when you get the Session Count on such an assembly, instead of 1, you get 3 and the Session Type is described to be as AD_ASSEMBLY, AD_PART, AD_PART, with AD_PART for the part sessions that the assembly has.

So, in your case, as you are getting the last index, I suppose your assembly has a part occurrence as the last item in it and hence you are getting the part session.

I am also assuming that you are accessing the sessions via the IADRoot object and not the IADAutomationHook object, because, there is no method on the Automation Hook object that lets you access the sessions.

Let me know if need more clarification here.

Thanks,
Shubha
 

eneyer

Member


Ohhhhhh

I was under the impression that sessions were openned models which could be either parts or assemblies. The last index would then be the last model that was openned.

I dont know if there is access to such a feature, but all I need is the active document anyhow. It works perfectly now. Thank you for your help.

-Eric
 
Top