iLogic Block Swapping

As part of their iLogic design Automation, one of our clients asked for some code today to swap Autodesk Inventor sketch blocks within their part sketches as they pick different options within their dialog boxes.  

iLogic Block Swapping

I remembered I'd had the same request a few years ago and dregged up my old code and found a video of it ... Do you remember when Inventor looked like this?

I thought this code could still be of use to more than one of you and so here is the basic version of it:


'Symetri iLogic

Dim oPartDoc As PartDocument

      oPartDoc = ThisApplication.ActiveDocument

Dim oCompDef As PartComponentDefinition

      oCompDef = oPartDoc.ComponentDefinition

Dim oSketches As PlanarSketches

      oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches

Dim oSketch As PlanarSketch

      oSketch = oSketches.Item(“Profile”)

oSketch.Edit

oSketch.sketchblocks.item(1).delete

Dim oSketchBlockDef As SketchBlockDefinition

      oSketchBlockDef = oCompDef.SketchBlockDefinitions.Item(TABLE_PROFILE)

Dim oPosition As Point2d

      oPosition = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)

’ Insert the sketch block definition

oSketch.SketchBlocks.AddByDefinition(oSketchBlockDef, oPosition)

oSketch.exitedit


If its of interest and you want to push it further then please get in touch. I do love a good bit of Automation awesomeness! ;)

iLogic is part of Autodesk Inventor and Inventor Professional.


Hidden Risks You Might Be Ignoring

21 May 2025

In this month’s IT Bulletin, we’re shedding light on the cybersecurity threats that often go unnoticed — but can have serious consequences for businesses of any size.

How to Simplify Configuration for your Engineering Software

20 May 2025

In this blog, we’ll look at some common challenges teams face when configuring engineering software and share practical tips on how to simplify the process. We’ll also explain how Symetri’s solutions can help you optimise your software setup, reduce errors, and keep your projects running smoothly.

4 ways to optimise your construction projects in the cloud

19 May 2025

Managing a growing number of Autodesk BIM 360 or Autodesk Construction Cloud (ACC) projects can quickly become overwhelming - especially when it comes to project setup, user management, and data backups. With the right tools, you can eliminate manual inefficiencies, boost productivity, and focus on more strategic initiatives. If your team works with BIM 360 or ACC, this blog focuses on four powerful ways Naviate Cloud Manager can streamline your operations.