Hi EMiller29. Yes I've been creating a lot of automated drawings since my post. It's really cool once it works 🙂
A few tips:
- I have made it a habit of creating one rule per view. Depending on how many dimensions you are creating, this is an easier way to troubleshoot the code and keep it clean and tidy.
- Anything in the code below that is in "" you have to adjust to what you have in your model/drawing (i.E. View "A", change the "A" to whatever your view is named).
My "standard" code for pretty much any part I want to have an automated drawing for looks like this. It's nicely organized I feel and you can use it for many other drawings by making minor adjustments. This example is to create a diameter dimension between 2 workpoints that "travel" with the Inner Diameter of the part (meaning they move if my Diameter increases or decreases), add a diameter symbol in front and center the text and add attributes so they can be deleted when you run that iLogicCreatedDelete rule that is mentioned in the video you linked to.
SyntaxEditor Code Snippet
'---INITIAL SETUP---------
'References this document
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDoc.Document
'References this drawing sheet
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
'References this drawing view
Dim oView As DrawingView
oView = ActiveSheet.View("A").View
'References all drawing views
Dim oViews as DrawingViews
oViews = oSheet.DrawingViews
'References this drawing view model
Dim oPartDoc As PartDocument
oPartDoc = ActiveSheet.View("A").ModelDocument
'Readys code for Creation of reference points for dimension placement
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
'Readys code for creation of general dimensions
Dim oGeneralDims As GeneralDimensions
oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions
'---DIMENSION PREP------------
'finds point with a particular attribute then takes the first instance
Dim WorkPoint1 As WorkPoint
oObjs = oPartDoc.AttributeManager.FindObjects("DIM", "PT_ID_TOP", "1")
WorkPoint1 = oObjs.Item(1)
Dim WorkPoint2 As WorkPoint
oObjs = oPartDoc.AttributeManager.FindObjects("DIM", "PT_ID_BTM", "1")
WorkPoint2 = oObjs.Item(1)
'"includes" work point in the view and turns them into centermarks so we 'can dimension To them
Dim marks(2) As Centermark
marks(0) = oSheet.Centermarks.AddByWorkFeature(WorkPoint1, oView)
marks(0).Visible = False
marks(1) = oSheet.Centermarks.AddByWorkFeature(WorkPoint2, oView)
marks(1).Visible = False
'creates intents, needed for Inventor to know that we want to use these points to'create dimensions further down in the code
Dim intent1 As GeometryIntent
intent1 = oSheet.CreateGeometryIntent(marks(0))
Dim intent2 As GeometryIntent
intent2 = oSheet.CreateGeometryIntent(marks(1))
'ID position for dimension
Dim oPt1 As Point2d
oPt1 = oTG.CreatePoint2d(oView.Left - 1)
'---CREATING DIMENSIONS------------
'creates ID dimension to the left of the view
Dim oID As GeneralDimension
oID = oGeneralDims.AddLinear(oPt1, intent1, intent2)
oID.CenterText
'adds ø-symbol in front Of dimension value
Dim oIDText As DimensionText = oID.Text
oIDText.FormattedText = "ø<DimensionValue/>"
'---ADDING ATTRIBUTES TO DIMENSIONS------------
'Adds an attribute to the dimensions. This is necessary to automatically'delete them when the "Delete_iLogic_Created" rule is run.
Dim oDim1Att As AttributeSet
ODim1Att = oID.AttributeSets.Add("iLogic_Created")
ODim1Att = oID.AttributeSets.Add("ID")
I hope that helps. If you have any questions about the code or for any other options you want to build into your drawing, don't hesitate to hit me up 🙂