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.


Unlock Your Potential: The Benefits of Investing in a Learning Path with Symetri

26 February 2025

At Symetri, we understand the importance of tailored education and deliver exceptional training solutions, available both in our classrooms or through our unique Virtual Classroom. Here, we explore the many advantages of committing to a learning path with Symetri and how it can transform both personal and professional growth.

Strengthening Cybersecurity & IT Best Practices

26 February 2025

As businesses continue to rely on digital tools and internet connectivity, cyber risks remain a constant concern. This month, we're exploring three important topics: the hidden risks of public Wi-Fi, the importance of regular IT audits, and QR code security. These insights will help you stay secure and ensure your business IT infrastructure remains resilient.

Boost Your Security and Productivity: Essential IT Insights

19 January 2025

As we enter the new year, it's crucial to stay informed about the latest tools and strategies to safeguard your digital life and optimise productivity. This month, we're focusing on three essential topics to help you strengthen cybersecurity practices and make the most of your technology. Learn how password managers can protect your sensitive information, understand the rising threat of malvertising and how to avoid it, and explore smart Windows 11 settings designed to boost efficiency in your daily tasks. These insights are designed to empower you with practical tips to stay secure and work smarter in 2025.