How to create an occurrence proxy?

How to create an occurrence proxy?

bshbsh
Collaborator Collaborator
3,458 Views
10 Replies
Message 1 of 11

How to create an occurrence proxy?

bshbsh
Collaborator
Collaborator

Hi,

in a VBA macro, I need to select an AssemblyComponentOccurrence by adding it to the SelectSet. This works fine already.

The problem is when the macro is ran on a subassembly in an "in place edit" situation, then I need to create a proxy of that comp.occurrence from the ActiveEditDocument, and add it to the ActiveDocument.SelectSet instead. How do I do this?

Thanks for any help.

0 Likes
3,459 Views
10 Replies
Replies (10)
Message 2 of 11

JaneFan
Autodesk
Autodesk

Hey @bshbsh

 

Please try following code, oProxy is the component occurrence proxy object.

Sub Test()
Dim topAssy As AssemblyDocument
Set topAssy = ThisApplication.ActiveDocument

Dim oOcc As ComponentOccurrence
'This can be the one you said: topAssy.SelectSet.Item(1)
Set oOcc = topAssy.SelectSet(1)
'Set oOcc = topAssy.ComponentDefinition.Occurrences(1)
Dim oSubOcc As ComponentOccurrence
Set oSubOcc = oOcc.SubOccurrences(1)

Dim oProxy As ComponentOccurrenceProxy
Call oOcc.CreateGeometryProxy(oSubOcc, oProxy)
End Sub




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 11

bshbsh
Collaborator
Collaborator

Hey JaneFan,

Although the programming help specifically states that the creategeometryproxy needs a geometry object input, I did try it already. But it threw me a type mismatch error. I didn't explicitly defined the result object type as a proxy though. Maybe I'll give it another try.

I also need to work out the proxy from the bottom up which is cumbersome.

0 Likes
Message 4 of 11

bshbsh
Collaborator
Collaborator

I didn't have time to work on this further, but now I do. I couldn't figure out yet how to do this. So I'm open for more suggestions. 🙂 These proxies are completely incompatible with my head.

0 Likes
Message 5 of 11

dgreatice
Collaborator
Collaborator

Hi,

 

this "create occurrences proxy" purpose to create constraints?

 

base on this sample, create occurrence proxy set to object like Work plane, work axis.

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-93F78CA8-4456-4421-BD8C-8D85037C5688

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 6 of 11

bshbsh
Collaborator
Collaborator

No... This is a really simple example, with conveniently hardcoded occurrences and no sub-assemblies or anything like that.

I am trying to use the built-in command "AppZoomSelectedCmd" to zoom on two occurrences. The macro needs to "select" the two occurrences for this command to work, i.e. put them into the selectset. However, if one works in a sub-sub-sub-assembly in in place edit mode (ie the ActiveEditDocument is a sub-sub-occurrence of the ActiveDocument), then the selectset used by that command is still in the ActiveDocument. So I need to "select" the two sub-occurrences in the context of the ActiveDocument, so I need to make proxies. The problem is, I haven't found a way to do this, I would have to find "parent occurrences" backwards, from the sub-sub-sub-assembly back to the top level. I'd think the "parent" property of an occurrence would do this, but it's not. Neither does the "containing occurrence". I even tried tracing backwards using the browserpane.

 

0 Likes
Message 7 of 11

bshbsh
Collaborator
Collaborator

Ok, I've found a strange solution that seems to work: get the BrowserNode of the "to be selected" object from the BrowserPane of the ActiveDocument, and it's NativeObject seems to give the proxy, straight, no hassle.

Dim InvModelTree As BrowserPaneObject
Set InvModelTree = ThisApplication.ActiveDocument.BrowserPanes.Item("AmBrowserArrangement")
Set BNode = InvModelTree.GetBrowserNodeFromObject(Occ)
Set OccProxy = BNode.NativeObject

This can be added to ActiveDocument.Selectset and works with built in commands. It also works for Occurrences, Constraints, etc. A little slow, though, and I don't know if it can fail (currently testing).

I still can't believe that there is no other way to find parent occurrences of something. It seems weird to me that it must happen through the BrowserPanes.

0 Likes
Message 8 of 11

Anonymous
Not applicable

This might be an old thread but it is not closed yet.

I tried node code above and for me it does not work. bNodeNativeObject does not return ComponentOccurrenceProxy object but ComponentOccurrence object. Did you happen to solve your problem?

0 Likes
Message 9 of 11

JamieVJohnson2
Collaborator
Collaborator

ComponentOccurrence is the host that creates proxies of its internal geometry.  Since the node is in reference of its assembly parent node, you will not get (nor need too) the ComponentOccurrenceProxy from a node.

 

Nor Need Too:  The node also has a Parent (node or pane) to get you up the tree.  For you to get to the very top, you will need to chase up the parent tree, then create a c.o. from the top level assembly to c.o.pxy. path back down to your selected occurrence, or use the suboccurrences method to chase down.

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 10 of 11

Anonymous
Not applicable

My assembly is like this:

Assembly

-Part1

--Feature

--Pattern feature

-Part2

What I am trying to do is to reference PatternFeature as a proxy by using Feature this pattern is made from. This is because Part2 is already constrained against Feature. My Feature is a proxy, but when I get Pattern Feature it is not a proxy so I cannot pattern Part2 against this patternfeature.

I though thisnode code will be (awkward) solution but it is not.

Do you have a suggestion on how to get what I need?

0 Likes
Message 11 of 11

Anonymous
Not applicable
0 Likes