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.


Strengthen Your File Security & Cyber Awareness

18 April 2025

As cyber threats continue to grow more complex, securing how we store, manage, and share data is critical. This month’s bulletin dives deep into three key topics: how to ensure safe file storage and transfers, understanding the risks and benefits of password managers, and identifying the top cyber threats to watch in 2025. Whether you’re a business leader or an everyday user, taking proactive steps now can prevent serious problems down the road.

OPTIMISING BIM & DIGITAL: IN ARCHITECTURE & ENGINEERING

14 April 2025

Optimising BIM and digital tools in architecture and engineering is revolutionising the industry. By integrating technologies like AI, cloud computing, and data analytics, professionals can enhance collaboration, reduce errors, and streamline workflows. In this blog, we'll explore how leveraging these tools can lead to more efficient and successful project outcomes.