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: 

unlock and design view reps

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
CAD-One
1027 Views, 4 Replies

unlock and design view reps

I have a assembly with several locked design view reps.

I insert a couple of new parts to assembly.

 

Now, do i have to manually unlock each of the design reps to have these new parts visible in the each of then design view reps?

 

If yes, does any one have any macro or ilogic tool to do this?

 

 

C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020
4 REPLIES 4
Message 2 of 5
Curtis_Waguespack
in reply to: CAD-One

Hi CAD-One,

 

Here is a quick iLogic rule to find the active view rep, unlock all view reps, place a component, then relock all view reps, then unlock the active view rep. It's not perfect but should provide an example that you can tweek.

 

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

 

 

 'set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'define view rep 
Dim oViewRep As DesignViewRepresentation

'record the active view rep name
Dim sActiveViewRep as String
sActiveViewRep = oAsmCompDef.RepresentationsManager.ActiveDesignViewRepresentation.Name

'Unlock the View Reps
For Each oViewRep in oAsmCompDef.RepresentationsManager.DesignViewRepresentations
'skip the master view rep
If  oViewRep.DesignViewType = DesignViewTypeEnum.kMasterDesignViewType Then 'do nothing
'skip any private view reps
ElseIf oViewRep.DesignViewType = DesignViewTypeEnum.kPrivateDesignViewType Then 'do nothing
Else
'unlock the View Rep
	If oViewRep.locked = True Then
	oViewRep.locked = False
	End If
End If
Next

'Place a component
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"
oFileDlg.DialogTitle = "Select a File to Place"
oFileDlg.InitialDirectory = ThisDoc.Path
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
MessageBox.Show("File not chosen.", "Dialog Cancellation")
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
    
' Create a matrix.  
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence

'place an instance of the component 
'in this case at 0,0,0
oOccurrence = oAsmCompDef.Occurrences.Add(selectedfile, oMatrix) 

' Set the translation portion of the matrix so the part will be 
'positioned at the co-ordinates
oMatrix.SetTranslation(oTG.CreateVector(0, 0, 1)) 
End If

'Re-Lock the View Reps
For Each oViewRep in oAsmCompDef.RepresentationsManager.DesignViewRepresentations
'skip the master view rep
If oViewRep.DesignViewType = DesignViewTypeEnum.kMasterDesignViewType Then 'do nothing
'skip any private view reps
ElseIf oViewRep.DesignViewType = DesignViewTypeEnum.kPrivateDesignViewType Then 'do nothing
Else
'lock the rest of the View Reps
	If oViewRep.locked = False Then
	oViewRep.locked = True
	End If
End If
Next

'unlock the last active View Rep
oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sActiveViewRep) 
oViewRep.Locked = False
oViewRep.Activate

iLogicVb.UpdateWhenDone = True

 

Message 3 of 5
CAD-One
in reply to: Curtis_Waguespack

Thanks Curtis.

 

I get error on line 9, 12, 59 and 73.

 

Can you guide me on how to fix?

C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020
Message 4 of 5
Curtis_Waguespack
in reply to: CAD-One

Hi CAD-One,

 

My guess is some copy/paste formating issue with the forum. Attached is the same code in the *.txt file that should work better.

 

If you still get the errors let me know and I'll try to have another look.

 

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

Message 5 of 5
CAD-One
in reply to: Curtis_Waguespack

Curtis, You saved ton of my time. Thanks

C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020

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

Post to forums  

Autodesk Design & Make Report