- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It took me some practice adding dimensions in the drawing document, because it is definitely picky about input.
First, you want an Object Collection (examples below are from my own code, so use your own names), because when you're done adding these dims the collection can be used to clean them up, with the arrange command.
Dim ocSideViewSideDims As ObjectCollection = invApp.TransientObjects.CreateObjectCollection
sheet1.DrawingDimensions.Arrange(ocSideViewTopDims)
So with that end in mind, here I am adding a Linear dimension to the drawing, and to the collection in one line.
ocSideViewTopDims.Add(sheet1.DrawingDimensions.GeneralDimensions.AddLinear(pDimText, giLoadShiftCenter, giLoadShiftRight, DimensionTypeEnum.kHorizontalDimensionType))
Function AddLinear(TextOrigin As Point2d, IntentOne As GeometryIntent, Optional IntentTwo As Object = Nothing, Optional DimensionType As DimensionTypeEnum = DimensionTypeEnum.kAlignedDimensionType, Optional ArrowheadsInside As Boolean = True, Optional DimensionStyle As Object = Nothing, Optional Layer As Object = Nothing) As LinearGeneralDimension
Getting GeometryIntent will be the biggest challenge, because it is so 'vague'.
Function CreateGeometryIntent(Geometry As Object, Optional Intent As Object = Nothing) As GeometryIntent
I used Centerlines for the object (turned on, or included, from model workplanes), Then using TransientGeometry(tg=invApp.TransientGeometry) create a pick point for placement that is relevant to that object. Its like saying, here is a box solid, and here is the top right corner of that box solid. Or Here is a centerline, and here is the end point on that centerline.
Dim giLoadShiftCenter As GeometryIntent = sheet1.CreateGeometryIntent(clSideYZ, tg.CreatePoint2d(clSideYZ.StartPoint.X, cmMaxBottomSideView.Position.Y))
Dim giLoadShiftRight As GeometryIntent = sheet1.CreateGeometryIntent(cmMaxRightSideView)
pDimText = tg.CreatePoint2d(FindMid(clSideYZ.EndPoint.X, cmMaxRightSideView.Position.X), cmMaxTopSideView.Position.Y + (2 * DimOffset))
If it gives you 'EFail' its is likely the input doesn't work as you expected. Your point may not be on your object, or your object may be missing altogether. From there go back and trace your input values, and verify you are in-fact telling it not to jump off a cliff.