Inventor General

Reply
Mentor
CAD-One
Posts: 712
Registered: ‎10-26-2008
Message 1 of 5 (345 Views)
Accepted Solution

unlock and design view reps

345 Views, 4 Replies
11-27-2012 09:45 AM

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 2013
Vault Collaboration 2013
*Expert Elite*
Curtis_Waguespack
Posts: 2,801
Registered: ‎03-08-2006
Message 2 of 5 (335 Views)

Re: unlock and design view reps

11-27-2012 11:20 AM 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

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Mentor
CAD-One
Posts: 712
Registered: ‎10-26-2008
Message 3 of 5 (322 Views)

Re: unlock and design view reps

11-27-2012 01:01 PM 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 2013
Vault Collaboration 2013
*Expert Elite*
Curtis_Waguespack
Posts: 2,801
Registered: ‎03-08-2006
Message 4 of 5 (317 Views)

Re: unlock and design view reps

11-27-2012 01:08 PM 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



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Mentor
CAD-One
Posts: 712
Registered: ‎10-26-2008
Message 5 of 5 (308 Views)

Re: unlock and design view reps

11-27-2012 01:29 PM in reply to: Curtis_Waguespack

Curtis, You saved ton of my time. Thanks

C1
Inventor Professional 2013
Vault Collaboration 2013

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube