Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

visibility of workplane in assembly

3 REPLIES 3
Reply
Message 1 of 4
sandhup
472 Views, 3 Replies

visibility of workplane in assembly

I can as much as I try make the workplanes in sub assembly not visible through the api. These are workplanes created in as assembly that are automatically created when sketching in an assembly - I had the same problem in R11 and R2008.

This is the snippet code it, when I run through it runs but the workplanes are still visible:

Dim oPartCompDef As AssemblyComponentDefinition
Set oPartCompDef = oOccurrence.Definition

Dim n As Integer
For n = 3 To oOccurrence.Definition.WorkPlanes.count
If oPartCompDef.WorkPlanes.Item(n).Visible = True Then
Dim oWorkPlane As WorkPlane
Set oWorkPlane = oPartCompDef.WorkPlanes.Item(n)
oWorkPlane.Visible = False
End If
Next

THERE IS NO CHANGE TO WORKPLANE STATE
3 REPLIES 3
Message 2 of 4
sandhup
in reply to: sandhup

It changes the visibility of the sub-assembly when its opened up. But doesnt change is visibility in the main assembly that the code needs to do. Changes in oOccurrence should persist in the main assembly, I can seem to change the workplane. Help Appreciated
Message 3 of 4
Anonymous
in reply to: sandhup

If you are familiar with the concept of proxies, you need to get the
WorkPlaneProxy object in the context of the top level assembly (active
assembly) and set the Visible property on that object. Your code jumps over
to the sub-assembly or part document and sets the visibility of the
workplane in that document.

Sanjay-

wrote in message news:5781902@discussion.autodesk.com...
It changes the visibility of the sub-assembly when its opened up. But doesnt
change is visibility in the main assembly that the code needs to do. Changes
in oOccurrence should persist in the main assembly, I can seem to change the
workplane. Help Appreciated
Message 4 of 4
rob.j.ross
in reply to: sandhup

I am also trying to hide all workplanes in an assembly and am having trouble getting it to work. I have tried three methods found in various threads to no avail. They are:

1) Going directly to the occurrence in the assembly and turning the workplanes off. (assumes all parts in assembly are sub assemblies)

Dim oPlane As WorkPlane
Dim oPlanes As WorkPlanes
Dim oOccurrences As ComponentOccurrences
Dim oOccurrence As ComponentOccurrence
Dim oAssyCompDef As AssemblyComponentDefinition
Dim oSubAssyCompDef As AssemblyComponentDefinition

Set oOccurrences = oAssyCompDef.Occurrences

For Each oOccurrence In oOccurrences
Set oSubAssyCompDef = oOccurrence.Definition
Set oPlanes = oSubAssyCompDef.WorkPlanes

For Each oPlane In oPlanes
oPlane.Visible = False
Next
Next

2) Creating proxies of the workplanes with respect to the top level assembly and turning their visibility off.

Dim oPlane As WorkPlane
Dim oPlaneProxy As WorkPlaneProxy
Dim oPlanes As WorkPlanes
Dim oOccurrences As ComponentOccurrences
Dim oOccurrence As ComponentOccurrence
Dim oAssyCompDef As AssemblyComponentDefinition
Dim oSubAssyCompDef As AssemblyComponentDefinition

Set oOccurrences = oAssyCompDef.Occurrences

For Each oOccurrence In oOccurrences
Set oSubAssyCompDef = oOccurrence.Definition
Set oPlanes = oSubAssyCompDef.WorkPlanes

For Each oPlane In oPlanes
Call oOccurrence.CreateGeometryProxy(oPlane, oPlaneProxy)
oPlaneProxy.Visible = False
Next
Next

3) Using "AppAllWorkFeaturesCmd" control definition (Sanjay's code)

'Get the "Object Visibility -> All Workfeatures" command
Dim oCtrlDef As ButtonDefinition
Set oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppAllWorkfeaturesCmd")

'Check whether the option is checked. If it is, uncheck it.
If oCtrlDef.Pressed Then
MsgBox "Pressed"
oCtrlDef.Execute
End If

I cannot get any of these to turn off a plane in a subassembly that I don't want. The workplane is in a subassembly which is at the top level of the main assembly.

Main Assembly
-SubAssembly1
--Offending WorkPlane
-SubAssembly 2
...

What am I doing wrong here?
____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report