Move occurrences with same filename

Move occurrences with same filename

Anonymous
Not applicable
625 Views
2 Replies
Message 1 of 3

Move occurrences with same filename

Anonymous
Not applicable

(inventor 2017.4)

 

I use iLogic to go through all ReferencedDocuments in an assembly. I search for specific iProperties to get the filenames of files that match my criteria.

 

Can someone please help me set the moveOcc ComponentOccurrence with the help of my filename and not the occurrence name. I assume the problem is that one filename can be several difference occurrences. (se below snippet of my code)

 

So what in summary what i would like to do: Move all occurrences with a specific filename to a specific coordinate and ground it/them

 

 

Dim moveOcc As ComponentOccurrence = Component.InventorComponent("myoccurrence:1")

Dim oTransform As Matrix = moveOcc.Transformation

oTransform.SetTranslation(ThisApplication.TransientGeometry.CreateVector(stay4*convFactor, 0*convFactor, 0*convFactor))
moveOcc.Transformation = oTransform
moveOcc.Grounded = True

 

Any input would really be appreciated

 

0 Likes
Accepted solutions (1)
626 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor
Accepted solution

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-0C5859C6-83AB-4F62-A92B-73B419DFE96C

 

oFileNameToMove = "C:\Test.ipt"
oDocToMove = ThisApplication.Documents.Open(oFileNameToMove, True)

For Each oOcc As Occurrence in oParentAsm.AllReferencedOccurrences(oDocToMove)
    'Do your stuff
Next

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for your reply, 

 

I didn't manage to use the code you supplied (my bad, i really need to learn ilogic form the beginning instead of copy paste until it works)

 

i used 

 

SyntaxEditor Code Snippet

        For Each oOccurrence In asmDef.Occurrences
        
            If iProperties.Value(oOccurrence.Name, "Summary", "Title") = "Jib Stay Brackets" Then
                moveOccName = oOccurrence.Name 'Set the occurrence name to move
            End If
        Next

 

Since this time i only needed to move one occurrence it works okay. 

0 Likes