ProcessViewSelection

ProcessViewSelection

Anonymous
Not applicable
607 Views
9 Replies
Message 1 of 10

ProcessViewSelection

Anonymous
Not applicable
Could anybody give me an example on how to use ProcessViewSelection?

I have the GenericObject from a selectset, but I'm stuck on how to get further...

In my SelectSet is a GenericObject, resulting form selecting a part in a view (part priority). This view contains an assembly and I want to get the filename/fileObject of the selected part.

Hope this made sense to some of you 🙂

Ronny
0 Likes
608 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
I've attached some code to demonstrate. The returned oSelectedObj in your
case should be a ComponentOccurrence object in the context of the top level
assembly. ComponentOccurrence.Definition.Document returns the Part document
of interest.

Sanjay-

Sub ProcessSelection()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oGenObj As GenericObject
Set oGenObj = oDoc.SelectSet(1)

Dim oView As DrawingView
Dim oSelectedObj As Object

Call oDoc.ProcessViewSelection(oGenObj, oView, oSelectedObj)

End Sub


wrote in message news:5683802@discussion.autodesk.com...
Could anybody give me an example on how to use ProcessViewSelection?

I have the GenericObject from a selectset, but I'm stuck on how to get
further...

In my SelectSet is a GenericObject, resulting form selecting a part in a
view (part priority). This view contains an assembly and I want to get the
filename/fileObject of the selected part.

Hope this made sense to some of you 🙂

Ronny
0 Likes
Message 3 of 10

rschader
Advocate
Advocate
Perhaps this code snippet I used will help you:

' if we get a IRxGenericObject, see what other kind of info we can get.
If TypeName(oMyEnt1) = "IRxGenericObject" Then
Dim oDrawView As DrawingView
Dim gObject As Object
' can we assume that we have a drawingdocument if we get a generic object?
' let's find out.
oDoc.ProcessViewSelection oMyEnt1, oDrawView, gObject
MsgBox "Generic Object Type: " & TypeName(gObject)
'IRxComponentOccurence + IRxComponentOccurenceProxy ok
'IRxRevolveFeature good.
'IRxChamferFeature good.
'IRxExtrudeFeature good.
'IRxNonParametricBaseFeature good.
'IRxHoleFeature ok
'IRxShellFeature ok
'IRxFilletFeature ok
'IRxSplitFeature ok
'IRxSweepFeature ok

'WorkPoints/axes choke at assigning the selectset.

End If

The comment lines show what I had tested and was able to get results for or not. ALot of these objects are returned as their native (non generic) in IV2008. Which version are you using?

Bob S.
0 Likes
Message 4 of 10

Anonymous
Not applicable
OK, so I need to do some more checking than just to assume this is a part.
Yes, I use IV2008 SP1 (of course??? ;-)).
Just a thought:
If I first check to see if the selection filter is set to part priority, can I then assume it is a part in the SelectSet? (If I actually can check this...)
0 Likes
Message 5 of 10

Anonymous
Not applicable
Thank you Sanjay, this worked just fine.
The API-help could have been a bit more descriptive, if it had said that the method will return the View and the selected object I probably would figure out this myself...
The API-help should have more detailed descriptions and examples of how to use the different methods and functions...

Ronny
0 Likes
Message 6 of 10

Anonymous
Not applicable
This code you provided works fine, but not completely...
If the selectset contains a section line, this fails.
How can i check if the selection is a section line? I have made som debugging code like this:

oGeneric = oSelectset(1)
Dim test = TypeName(oGeneric)

If I select a part, test="IRxGenericObject"
and if I select a section line, test="IRxGenericObject"
So I can not check whether oGeneric is of type "IRxGenericObject".
How can I decide if my selection is a section line?

Ronny

Reply From: Sanjay Ramaswamy \(Autodesk\)
Date: Aug/08/07 - 20:12 (CEST)

Re: ProcessViewSelection
I've attached some code to demonstrate. The returned oSelectedObj in your
case should be a ComponentOccurrence object in the context of the top level
assembly. ComponentOccurrence.Definition.Document returns the Part document
of interest.

Sanjay-

Sub ProcessSelection()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oGenObj As GenericObject
Set oGenObj = oDoc.SelectSet(1)

Dim oView As DrawingView
Dim oSelectedObj As Object

Call oDoc.ProcessViewSelection(oGenObj, oView, oSelectedObj)

End Sub
0 Likes
Message 7 of 10

Anonymous
Not applicable
Unfortunately, there isn't an API object that represents a section line. So
there isn't a way to determine if the selected object is a section line.
Sorry.

Sanjay-

wrote in message news:5701036@discussion.autodesk.com...
This code you provided works fine, but not completely...
If the selectset contains a section line, this fails.
How can i check if the selection is a section line? I have made som
debugging code like this:

oGeneric = oSelectset(1)
Dim test = TypeName(oGeneric)

If I select a part, test="IRxGenericObject"
and if I select a section line, test="IRxGenericObject"
So I can not check whether oGeneric is of type "IRxGenericObject".
How can I decide if my selection is a section line?

Ronny

Reply From: Sanjay Ramaswamy \(Autodesk\)
Date: Aug/08/07 - 20:12 (CEST)

Re: ProcessViewSelection
I've attached some code to demonstrate. The returned oSelectedObj in your
case should be a ComponentOccurrence object in the context of the top level
assembly. ComponentOccurrence.Definition.Document returns the Part document
of interest.

Sanjay-

Sub ProcessSelection()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oGenObj As GenericObject
Set oGenObj = oDoc.SelectSet(1)

Dim oView As DrawingView
Dim oSelectedObj As Object

Call oDoc.ProcessViewSelection(oGenObj, oView, oSelectedObj)

End Sub
0 Likes
Message 8 of 10

Anonymous
Not applicable
OK, I can get around it with a try...catch...end try, with no code in the catch "area", but it is not very elegant... Perhaps in the future??

Thanks anyway.

Ronny
0 Likes
Message 9 of 10

Anonymous
Not applicable
Sanjay,
Digging up an old post, but...
The code here works well for features in sheet metal formed views, but returns a part document when selecting with feature priority into a flat view. Is there a way to access sheet metal features selected in the flat view? Is IV2010 better here than IV2009? Will addins do what VBA cannot? The goal is to automate callout of punch tool features in a way that the 2009 annotion won't do.

Brian.
0 Likes
Message 10 of 10

Anonymous
Not applicable

Yes, things should work better in Inventor 2010.
The features within a flat pattern were not exposed via the API prior to
Inventor 2010.

 

Sanjay-
0 Likes