I apologize for the slow reply. This code generates a large number of dimensions, so I took out the irrelevant parts and tested to make sure that I included all the relevant code.
I am using Autodesk Inventor Professional 2015.
The SlotCenter Attributes are workpoints at the centers of slots arranged in a circular patter. This code creates a circular centerline through those workpoints and dimensions its diameter. I used the Attribute Helper plugin to create the workpoint attributes in the model.
This code creates the dimension without any problems. But for some reason, the location of the dimension text jumps around. This typically only happens when the view is moved, but sometimes it jumps when the file is opened again after saving. It seems to jump to the horizontal origin of the diameter dimension.
Thank you for taking the time to reply to my post.
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oAssyDoc As AssemblyDocument
Dim oComp As Inventor.ComponentOccurrence
Dim oTG As TransientGeometry
Dim oGeneralDims As GeneralDimensions
Dim oIDEdge As Edge
Dim oIDEdgeProx As Inventor.EdgeProxy = Nothing
Dim oEdgeCurve As DrawingCurve
Dim oObjs As ObjectCollection
Dim oPt As Point2d
Dim oDim As GeneralDimension
Dim oCenterlines As Centerlines
oDoc = ThisDoc.Document
oSheet = oDoc.ActiveSheet
oAssyDoc = ThisDrawing.ModelDocument
oTG = ThisApplication.TransientGeometry
oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions
i = 1
rda = ""
Do Until rda = "name of stabilized subassembly"
oComp = oAssyDoc.ComponentDefinition.Occurrences.Item(i)
rda = oComp.Name
i = i + 1
Loop
oView = ActiveSheet.View("View1").View
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "AssemblyID", "1")
oIDEdge = oObjs.Item(1)
oComp.CreateGeometryProxy(oIDEdge, oIDEdgeProx)
oViewCurves = oView.DrawingCurves(oIDEdgeProx)
oEdgeCurve = oViewCurves.Item(1)
Dim oBCPoint1 As WorkPoint
Dim oBCPoint2 As WorkPoint
Dim oBCPoint3 As WorkPoint
Dim oBCPoint4 As WorkPoint
Dim oBCPoint5 As WorkPoint
Dim oBCPoint6 As WorkPoint
Dim oBCPoint7 As WorkPoint
Dim oBCPoint8 As WorkPoint
Dim oODPoint As WorkPoint
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter1", "1")
oBCPoint1 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter2", "1")
oBCPoint2 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter3", "1")
oBCPoint3 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter4", "1")
oBCPoint4 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter5", "1")
oBCPoint5 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter6", "1")
oBCPoint6 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter7", "1")
oBCPoint7 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "SlotCenter8", "1")
oBCPoint8 = oObjs.Item(1)
oObjs = oAssyDoc.AttributeManager.FindObjects("DIM", "pointOD", "1")
oODPoint = oObjs.Item(1)
oBCCM1 = oSheet.Centermarks.AddByWorkFeature(oBCPoint1, oView)
oBCCM2 = oSheet.Centermarks.AddByWorkFeature(oBCPoint2, oView)
oBCCM3 = oSheet.Centermarks.AddByWorkFeature(oBCPoint3, oView)
oBCCM4 = oSheet.Centermarks.AddByWorkFeature(oBCPoint4, oView)
oBCCM5 = oSheet.Centermarks.AddByWorkFeature(oBCPoint5, oView)
oBCCM6 = oSheet.Centermarks.AddByWorkFeature(oBCPoint6, oView)
oBCCM7 = oSheet.Centermarks.AddByWorkFeature(oBCPoint7, oView)
oBCCM8 = oSheet.Centermarks.AddByWorkFeature(oBCPoint8, oView)
oODCM = oSheet.Centermarks.AddByWorkFeature(oODPoint, oView)
oODCM.Visible = False
oCenterlines = oSheet.Centerlines
Dim oMarks1 As ObjectCollection
oMarks1 = ThisApplication.TransientObjects.CreateObjectCollection
oMarks1.Add(oBCCM1)
oMarks1.Add(oBCCM5)
Dim oGeometryIntent As GeometryIntent
oCL = oCenterlines.AddCenteredPattern(oSheet.CreateGeometryIntent(oEdgeCurve),oMarks1,,,True)
oPt = oCL.StartPoint
oGeometryIntent = oSheet.CreateGeometryIntent(oCL, oPt)
oPt = oTG.CreatePoint2d(oView.Left + 6.6, oView.Top - 4.4)
oDim = oGeneralDims.AddDiameter(oPt, oGeometryIntent)
oPt = oDim.Text.Origin
oPt.X = oPt.X - 1
oDim.Text.Origin = oPt
oDimAtt = oDim.AttributeSets.Add("iLogic_Created")