Hello guys,
I'm trying to make a code that automates a general dimension between the XY- planes of a subassembly in the idw enviroment
The main assembly has been named: assembly1 and the subassemblies as Test:1 and Test:2
After some googling i found this code, unfortunaly i’m unable to get it to work
See in the attachments for a visual explanation.
First : No Dimension
Second: The XY Planes of the sub-assemblies
Third: a generated general dimension between the two subassemblies.
the code so far:
Dim oDrawingDocument As DrawingDocument
oDrawingDocument = ThisApplication.ActiveDocument
oSheet = ThisApplication.ActiveDocument.ActiveSheet
oDrawingView = ActiveSheet.View("VIEW11").View
oAssemblyDocument = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
oTG = ThisApplication.TransientGeometry
Dim oOcc As ComponentOccurrence = ThisApplication.ActiveDocument.ReferencedDocuments(1).ComponentDefinition.Occurrences.ItemByName("Test:1")
Dim oOcc1 As ComponentOccurrence = ThisApplication.ActiveDocument.ReferencedDocuments(1).ComponentDefinition.Occurrences.ItemByName("Test2:2")
Dim wp1 As WorkPlane = oOcc.Definition.WorkPlanes.Item("XY Plane")
Dim wp2 As WorkPlane = oOcc1.Definition.WorkPlanes.Item("XY Plane")
Dim centerLine1 As Centerline = Nothing
Dim centerline2 As Centerline = Nothing
centerLine1 = oSheet.Centerlines.AddByWorkFeature(wp1, oDrawingView)
centerline2 = oSheet.Centerlines.AddByWorkFeature(wp2, oDrawingView)
Dim wInt1 As GeometryIntent = oSheet.CreateGeometryIntent(centerLine1, PointIntentEnum.kStartPointIntent)
Dim wInt2 As GeometryIntent = oSheet.CreateGeometryIntent(centerline2, PointIntentEnum.kStartPointIntent)
Dim oDimPos As Point2d = oTG.CreatePoint2d(centerLine1.StartPoint.X - 2, centerline2.StartPoint.Y)
Dim oDim As GeneralDimension '= Nothing
oDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oDimPos, wInt1, wInt2, DimensionTypeEnum.kHorizontalDimensionType)
Help is really appreciated.
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
I know of another approach to getting those lines to dimension between within your drawing view.
The DrawingView object has a couple of methods that you can use called "GetIncludeStatus", "SetIncludeStatus", "GetVisibility", & "SetVisibility".
You can use the SetIncludeStatus, then the SetVisibility to show the line on your drawing view that represents the plane. Then you can dimension between them.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.