Message 1 of 4
run ilogic rule to trigger mouse selection and perform a action

Not applicable
10-31-2013
05:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I am trying to put together a iLogic script that will perform this:
I want to select many inserted parts (unconstrained) in a assembly (with mouse) then run the flush to origin script I found in other sections of this forum
Im quite new to iLogic, but have tried to alter this script to perform the actions I want.
Any suggestions?
I dont want the script to insert a new part as this one do:
Trigger = iTrigger0 'get file to place 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" 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") Return ElseIf oFileDlg.FileName <> "" Then oFile = oFileDlg.FileName End If ' set a reference to the assembly component definintion. ' This assumes an assembly document is open. Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition ' 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 'place an instance of the component Dim oOccurrence As ComponentOccurrence oOccurrence = oAsmCompDef.Occurrences.Add(oPath & oFile, oMatrix) ' Set the translation portion of the matrix so the part will be 'positioned at the co-ordinates oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0)) 'check for grounded component, such as the first component in the assembly If oOccurrence.Grounded = True Then oGrounded = MessageBox.Show("Should this component be grounded?", _ "iLogic",MessageBoxButtons.YesNo) If oGrounded = vbNo Then oOccurrence.Grounded = False Else End If End If 'Get the plane from the selected part. ' The work plane obtained is in the context of the part, not the assembly. Dim oPartPlane1 As WorkPlane Dim oPartPlane2 As WorkPlane Dim oPartPlane3 As WorkPlane oPartPlane1 = oOccurrence.Definition.WorkPlanes.Item(1) 'Component YZ Plane oPartPlane2 = oOccurrence.Definition.WorkPlanes.Item(2) 'Component XZ Plane oPartPlane3 = oOccurrence.Definition.WorkPlanes.Item(3) 'Component XY Plane 'Get the plane from the assembly Dim oAsmPlane1 As WorkPlane Dim oAsmPlane2 As WorkPlane Dim oAsmPlane3 As WorkPlane oAsmPlane1 = oAsmCompDef.WorkPlanes.Item(1) 'Assembly YZ Plane oAsmPlane2 = oAsmCompDef.WorkPlanes.Item(2) 'Assembly XZ Plane oAsmPlane3 = oAsmCompDef.WorkPlanes.Item(3) 'Assembly XY Plane ' Create proxies for the work planes of the part. ' The proxies represent the part work planes in the context of the assembly. Dim oAsmPlane4 As WorkPlaneProxy Dim oAsmPlane5 As WorkPlaneProxy Dim oAsmPlane6 As WorkPlaneProxy oOccurrence.CreateGeometryProxy(oPartPlane1, oAsmPlane4) oOccurrence.CreateGeometryProxy(oPartPlane2, oAsmPlane5) oOccurrence.CreateGeometryProxy(oPartPlane3, oAsmPlane6)
I found the script to perform mouse selection, but have not been able to combine them
'get file to place Dim doc = ThisApplication.ActiveDocument Dim entity = ThisApplication.CommandManager.Pick( SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Component:") If (Not entity Is Nothing) Then MsgBox(entity.Name) End If