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

The Digital Transformation of 2020 & Beyond...

20 January 2021

2020 was a year like no other and saw many businesses having to completely transform the way their workforce operates with mobile solutions; a change in infrastructure that would normally have taken years to happen globally.

Learn more
Blog

Project and Template Standards in Revit MEP

20 January 2021

One of the great things about Revit MEP is that I can incorporate the standards for presentation, mechanical and electrical services, and deliverables into my project template so that every new project I create starts from the same position, saving me time, promoting consistency, and reducing errors in my project.

Learn more
Blog

Take good care of your emails or risk huge fines

18 January 2021

It seems like such a long time ago that we were all wondering how the General Data Protection Regulation (GDPR) would impact our businesses and it’s easy to imagine that the problem has now gone away, but ignore it, and you could be making an expensive mistake.

Learn more