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.

Blog

Paths to Net Zero: Insights for Sustainable AEC

10 December 2024

As the built environment sector accounts for nearly 40% of global CO₂ emissions, achieving net-zero carbon has evolved from aspiration to necessity. In response, Symetri hosted the Paths to Net Zero: Insights, Technologies, and Solutions webinar series in September 2024. This article distils key takeaways from the series, offering a snapshot of challenges, trends, and impactful approaches shaping the future of decarbonisation in the AEC industry. 

Learn more
Blog

Harnessing the Power of Technology: Insights from Symetri

26 November 2024

Symetri is dedicated to helping businesses thrive in a rapidly evolving technological landscape. From leveraging AI in Microsoft Teams to maximising the potential of Microsoft 365 and addressing the critical impacts of IT downtime, understanding and implementing the right tools and strategies is key to success. Below, we explore three significant areas shaping the modern workplace.

Learn more