Automate general dimension between 2 planes of a sub-assembly

Automate general dimension between 2 planes of a sub-assembly

Anonymous
Not applicable
702 Views
2 Replies
Message 1 of 3

Automate general dimension between 2 planes of a sub-assembly

Anonymous
Not applicable

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

https://forums.autodesk.com/t5/inventor-customization/creating-a-dimension-between-two-workplanes-in...

 

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.

0 Likes
Accepted solutions (1)
703 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted 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

EESignature

(Not an Autodesk Employee)

Message 3 of 3

Anonymous
Not applicable

Thank you very much. You pointed me in the right direction :). 

0 Likes