Inventor General Discussion

Inventor General Discussion

Reply
Valued Contributor
CJ.10E-10mm
Posts: 70
Registered: ‎06-21-2013
Message 21 of 28 (318 Views)

Re: ilogic and work plane visibility

10-03-2013 09:01 PM in reply to: Curtis_Waguespack

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

 

Valued Mentor
niksasa
Posts: 294
Registered: ‎12-28-2012
Message 22 of 28 (293 Views)

Re: ilogic and work plane visibility

10-20-2013 06:15 AM 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")

 

САПР - это инструмент, но только при условии грамотного подхода.
Valued Contributor
CJ.10E-10mm
Posts: 70
Registered: ‎06-21-2013
Message 23 of 28 (281 Views)

Re: ilogic and work plane visibility

10-20-2013 04:50 PM 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

 

 

Valued Mentor
niksasa
Posts: 294
Registered: ‎12-28-2012
Message 24 of 28 (265 Views)

Re: ilogic and work plane visibility

10-21-2013 12:08 AM 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

САПР - это инструмент, но только при условии грамотного подхода.
Valued Contributor
CJ.10E-10mm
Posts: 70
Registered: ‎06-21-2013
Message 25 of 28 (263 Views)

Re: ilogic and work plane visibility

10-21-2013 12:11 AM in reply to: niksasa

Not a problem Nicksasa,

 

Join the club! lol.

 

CJ

Valued Contributor
Millehuse
Posts: 53
Registered: ‎01-21-2011
Message 26 of 28 (203 Views)

Re: ilogic and work plane visibility

01-07-2014 01:27 AM 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?

Active Member
nomé
Posts: 10
Registered: ‎07-14-2008
Message 27 of 28 (64 Views)

Re: ilogic and work plane visibility

06-23-2014 04:41 AM 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

 

Valued Contributor
CJ.10E-10mm
Posts: 70
Registered: ‎06-21-2013
Message 28 of 28 (55 Views)

Re: ilogic and work plane visibility

06-23-2014 06:13 AM 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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.