Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic and work plane visibility

29 REPLIES 29
SOLVED
Reply
Message 1 of 30
rjones0215
7968 Views, 29 Replies

ilogic and work plane visibility

Is there a way to turn off visibility on work planes using ilogic?   Also, is there a way to change an extrusion type from an assymetrical extrusion to a one direction extrusion using ilogic?

Inventor 2013 Certified Professional
29 REPLIES 29
Message 21 of 30

Hi Curtis,

 

I came across your comprehensive reply and wondered if you could help me with a simpler problem please?

 

I have an assembly made up of identical sub assembles which in turn deploy identical parts. Thus I want to be able to turn off all work planes and just select a particular workplane in a particular sub-assembly to switch on and then off when I have finished with it. Otherwise my model is obscured often by hundreds of identical workplanes. At the moment I am having to select them individually in the Browser.

 

Thus I want a message box that allows me to turn on the workplane which I have physically selected in my browser. So that after selecting a particular work plane I could then choose either the 'Visible' or 'Invisible' Button in my message Box.

 

I am not sure if you will receive this message but if you do and you can help I would be most and I do mean MOST grateful.

 

Thank you.

 

CJ

 

Message 22 of 30
niksasa
in reply to: Curtis_Waguespack


Curtis_Waguespack написано:

Hi rjones0215, 

 

Here's another rule that toggles all of the workplanes on/off.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'define document
Dim oDoc As PartDocument
oDoc = ThisDoc.Document
'look at the workplane collection
For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
'toggle all work planes
If oWorkPlane.Visible = True Then
oWorkPlane.Visible = False
ElseIf oWorkPlane.Visible = False Then
oWorkPlane.Visible = True
End If
Next

 


If you want to turn on the visibility of a specified component?
ThisApplication.CommandManager.Pick (SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select component")

 

САПР - это инструмент, но только при условии грамотного подхода.
Message 23 of 30
CJ.10E-10mm
in reply to: CJ.10E-10mm

Hi Niksasa,

 

I am most grateful but can you help further please with this error message:

 

Error in rule: WorkPlanes, in document: ???.iam

Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

As I am in the top level Assembly with sub assemblies within sub assemblies and I too would like to be able to control all work features; would I be better using Curtis' alternative proposal of:

 

'get user input
oInput = InputRadioBox("Select work feature visibility:", _
 "Turn ON work features for all components", _
 "Turn OFF work features for all components", "False", "iLogic")

' set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Define the open document (top level assembly)
Dim openDoc As Document
openDoc = ThisDoc.Document
'define view rep
Dim oViewRep As DesignViewRepresentation
Dim sVRep as String
'change to something else if Default is used for something already
sVRep = "Default"

'create or activate view rep in the top level assembly
Try     
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate    
Catch
'create new View Rep
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try

'create or activate view rep in subassemblies
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
Dim subDoc As AssemblyComponentDefinition
If docFile.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
subDoc = docFile.ComponentDefinition
Try     
subDoc.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate    
Catch
'create new View Rep
subDoc.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try
Else
End If
Next

    'toggle work features in the open document (top level assembly)
    For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes
    If oInput = True Then
    oWorkPlane.Visible = True
    ElseIf oInput = False Then
    oWorkPlane.Visible = False
    End If
    Next

    For Each oWorkAxis In openDoc.ComponentDefinition.WorkAxes
    If oInput = True Then
    oWorkAxis.Visible = True
    ElseIf oInput = False Then
    oWorkAxis.Visible = False
    End If
    Next

    For Each oWorkPoint In openDoc.ComponentDefinition.WorkPoints
    If oInput = True Then
    oWorkPoint.Visible = True
    ElseIf oInput = False Then
    oWorkPoint.Visible = False
    End If
    Next

'look at only the subassemblies
Dim subDocFile As Document
For each oCompOcc in oAsmCompDef.Occurrences
If oCompOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oCompOcc.SetDesignViewRepresentation(sVRep,, True) 'True sets the view rep to be associative
Else
End If
Next


'Look at all of the files referenced in the open document
For Each docFile In openDoc.AllReferencedDocuments                

    'toggle work features in the components
    For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
    If oInput = True Then
    oWorkPlane.Visible = True
    ElseIf oInput = False Then
    oWorkPlane.Visible = False
    End If
    Next

    For Each oWorkAxis In docFile.ComponentDefinition.WorkAxes
    If oInput = True Then
    oWorkAxis.Visible = True
    ElseIf oInput = False Then
    oWorkAxis.Visible = False
    End If
    Next

    For Each oWorkPoint In docFile.ComponentDefinition.WorkPoints
    If oInput = True Then
    oWorkPoint.Visible = True
    ElseIf oInput = False Then
    oWorkPoint.Visible = False
    End If
    Next
Next
iLogicVb.UpdateWhenDone = True

 

Although this returns the error of:

 

Error in rule: WorkPlanes, in document: ???.iam

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

Can you help further please?

 

Many, many thanks,

 

CJ

 

 

Message 24 of 30
niksasa
in reply to: CJ.10E-10mm


CJ.10E-10mm написано:

Hi Niksasa,

 

I am most grateful but can you help further please with this error message:

 

Error in rule: WorkPlanes, in document: ???.iam

Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 Although this returns the error of:

 Error in rule: WorkPlanes, in document: ???.iam

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

Can you help further please?

 

Many, many thanks,

 

CJ

 

 


Hi CJ. I'm new to ilogic. So do not know if I can help

PS: sorry for bad english

САПР - это инструмент, но только при условии грамотного подхода.
Message 25 of 30
CJ.10E-10mm
in reply to: niksasa

Not a problem Nicksasa,

 

Join the club! lol.

 

CJ

Message 26 of 30
Millehuse
in reply to: david.campbell

I'm playing around with sample #4 - cause I often find myself opening old assemblies and being confronted with a million (at least) work planes, axis' odd stuff (see attachment) - and having to turn the visibility off manually - is time consuming.

 

I know you can hide the work features easilly with "Object Visibility" - but I want to turn the visibility off completely as part of our cleanup routine.

 

I get the following error though - when using sample #4 iLogic

 

 

Error in rule: WP, in document: 810.50.001.IAM

Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

 

System.Runtime.InteropServices.COMException (0x80020003): Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
   at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
   at LmiRuleScript.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Edited: Should clarify - it's the modified version of sample #4 - that handles all work features - not just work planes

Added extra error code information

 

Any thoughts?

Message 27 of 30
nomé
in reply to: Millehuse

A small addition to make also sketches invisible. 

Thanks for the source !!

 

For Each oSketches In openDoc.ComponentDefinition.Sketches
    If oInput = True Then
    oSketches.Visible = True
    ElseIf oInput = False Then
    oSketches.Visible = False
    End If
    Next

and

    For Each oSketches In docFile.ComponentDefinition.Sketches
    If oInput = True Then
    oSketches.Visible = True
    ElseIf oInput = False Then
    oSketches.Visible = False
    End If
    Next

 

 

'get user input
oInput = InputRadioBox("Select work feature visibility:", _
 "Turn ON work features for all components", _
 "Turn OFF work features for all components", "False", "iLogic")

' set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Define the open document (top level assembly)
Dim openDoc As Document
openDoc = ThisDoc.Document
'define view rep 
Dim oViewRep As DesignViewRepresentation
Dim sVRep As String
'change to something else if Default is used for something already
sVRep = "Default"

'create or activate view rep in the top level assembly
Try     
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate    
Catch
'create new View Rep
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try

'create or activate view rep in subassemblies
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
Dim subDoc As AssemblyComponentDefinition
If docFile.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
subDoc = docFile.ComponentDefinition
Try     
subDoc.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate    
Catch
'create new View Rep
subDoc.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try
Else 
End If
Next

    'toggle work features in the open document (top level assembly)
    For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes
    If oInput = True Then
    oWorkPlane.Visible = True
    ElseIf oInput = False Then
    oWorkPlane.Visible = False
    End If
    Next

    For Each oWorkAxis In openDoc.ComponentDefinition.WorkAxes
    If oInput = True Then
    oWorkAxis.Visible = True
    ElseIf oInput = False Then
    oWorkAxis.Visible = False
    End If
    Next

    For Each oWorkPoint In openDoc.ComponentDefinition.WorkPoints
    If oInput = True Then
    oWorkPoint.Visible = True
    ElseIf oInput = False Then
    oWorkPoint.Visible = False
    End If
    Next
	
    For Each oSketches In openDoc.ComponentDefinition.Sketches
    If oInput = True Then
    oSketches.Visible = True
    ElseIf oInput = False Then
    oSketches.Visible = False
    End If
    Next

'look at only the subassemblies
Dim subDocFile As Document
For Each oCompOcc in oAsmCompDef.Occurrences
If oCompOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oCompOcc.SetDesignViewRepresentation(sVRep,, True) 'True sets the view rep to be associative
Else 
End If
Next


'Look at all of the files referenced in the open document
For Each docFile In openDoc.AllReferencedDocuments                

    'toggle work features in the components
    For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
    If oInput = True Then
    oWorkPlane.Visible = True
    ElseIf oInput = False Then
    oWorkPlane.Visible = False
    End If
    Next

    For Each oWorkAxis In docFile.ComponentDefinition.WorkAxes
    If oInput = True Then
    oWorkAxis.Visible = True
    ElseIf oInput = False Then
    oWorkAxis.Visible = False
    End If
    Next

    For Each oWorkPoint In docFile.ComponentDefinition.WorkPoints
    If oInput = True Then
    oWorkPoint.Visible = True
    ElseIf oInput = False Then
    oWorkPoint.Visible = False
    End If
    Next
	
	For Each oSketches In docFile.ComponentDefinition.Sketches
    If oInput = True Then
    oSketches.Visible = True
    ElseIf oInput = False Then
    oSketches.Visible = False
    End If
    Next
Next
iLogicVb.UpdateWhenDone = True

 

Message 28 of 30
CJ.10E-10mm
in reply to: nomé

Dear nomé,

 

Thank you for your kind contribution.

 

I will try this out tonight and revert back to you.

 

Thank you once again.

 

CJJ

Message 29 of 30

Hi Curtis,

 

I'm looking to do something similar, but maybe simpler. I have this assembly with parts in it. I want to be able to toggle the visibility of workplanes in specific components. Not all of them at the same time. Is it possible?

 

'catch and skip errors
On Error Resume Next
'define the active assembly
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument

'get user input as True or False
wfBoolean = InputRadioBox("Turn all Work Features On/Off", "On", "Off", False, "iLogic")

'Check all referenced docs 
Dim oDoc As Inventor.Document
For Each oDoc In oAssyDoc.AllReferencedDocuments
    'set work plane visibility
    For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
    oWorkPlane.Visible = wfBoolean
    Next
    'set work axis visibility
    For Each oWorkAxis In oDoc.ComponentDefinition.WorkAxes
    oWorkAxis.Visible = wfBoolean
    Next
    'set work point visibility
    For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
    oWorkPoint.Visible = wfBoolean
    Next    
    'set sketch visibility
    For Each oSketch In oDoc.ComponentDefinition.Sketches
    oSketch.Visible = wfBoolean
    Next
Next

'update the files
InventorVb.DocumentUpdate()

 

I found this snippet online (that I think you may have wrote?) Anyway, I tried using as is, didn't work. I tried modifying it to fit my needs, didn't work either.

 


Message 30 of 30
caroline.ccc
in reply to: rjones0215

Can use this to turn off all work features.

 

ThisDoc.Document.ObjectVisibility.AllWorkFeatures = False

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

Post to forums  

Autodesk Design & Make Report