I have this code that works great for placing dimensions in a view now I would like to trigger the placement based off of a certain work point being present in the view. The work points will be one of the following:
WP_S_MP
WP_M_MP
WP_L_MP
WP_LM_MP
The rules the would need to run is as follows:
If WP_S_MP Then Dim HorizontalLengthPos1 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos1.InDatabaseUnits = WP_S_MP.PointOnSheet HorizontalLengthPos1.Y = HorizontalLengthPos1.Y - 1.5 * FRONT_VIEW.Scale Dim HorizontalLengthPos2 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos2.InDatabaseUnits = WP_S_MP.PointOnSheet HorizontalLengthPos2.Y = HorizontalLengthPos2.Y - 3 * FRONT_VIEW.Scale End If If WP_M_MP Then Dim HorizontalLengthPos3 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos3.InDatabaseUnits = WP_M_MP.PointOnSheet HorizontalLengthPos3.Y = HorizontalLengthPos3.Y - 1.5 * FRONT_VIEW.Scale Dim HorizontalLengthPos4 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos4.InDatabaseUnits = WP_M_MP.PointOnSheet HorizontalLengthPos4.Y = HorizontalLengthPos4.Y - 3 * FRONT_VIEW.Scale End If If WP_L_MP Then Dim HorizontalLengthPos5 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos5.InDatabaseUnits = WP_L_MP.PointOnSheet HorizontalLengthPos5.Y = HorizontalLengthPos5.Y - 1.5 * FRONT_VIEW.Scale Dim HorizontalLengthPos6 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos6.InDatabaseUnits = WP_L_MP.PointOnSheet HorizontalLengthPos6.Y = HorizontalLengthPos6.Y - 3 * FRONT_VIEW.Scale End If If WP_LM_MP Then Dim HorizontalLengthPos7 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos7.InDatabaseUnits = WP_LM_MP.PointOnSheet HorizontalLengthPos7.Y = HorizontalLengthPos7.Y - 1.5 * FRONT_VIEW.Scale Dim HorizontalLengthPos8 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos8.InDatabaseUnits = WP_LM_MP.PointOnSheet HorizontalLengthPos8.Y = HorizontalLengthPos8.Y - 3 * FRONT_VIEW.Scale End If
Help Please!
Solved! Go to Solution.
I think this should work for you
For Each oPoint As WorkPoint In ThisDoc.Document.ComponentDefinition.WorkPoints Select Case oPoint.Name Case "WP_S_MP" '... Case "WP_M_MP" '... Case "WP_L_MP" '... Case "WP_LM_MP" '... End Select Next
I assume from your other post it's coming from the bottom section of your code where you add the dimensions. You need to include those in your Select otherwise it will try to create dimensions for every type. Also you don't need to define a line for each one unless you plan to do more with them later.
Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions For Each oPoint As WorkPoint In ThisDoc.Document.ComponentDefinition.WorkPoints Select Case oPoint.Name Case "WP_S_MP" Dim HorizontalLengthPos1 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos1.InDatabaseUnits = WP_S_MP.PointOnSheet HorizontalLengthPos1.Y = HorizontalLengthPos1.Y - 1.5 * FRONT_VIEW.Scale Dim HorizontalLengthPos2 = ThisDrawing.Geometry.Point2d(0, 0) HorizontalLengthPos2.InDatabaseUnits = WP_S_MP.PointOnSheet HorizontalLengthPos2.Y = HorizontalLengthPos2.Y - 3 * FRONT_VIEW.Scale genDims.AddLinear("Dimension 1", HorizontalLengthPos, WP_S_F1_OE, WP_S_F1_IE) genDims.AddLinear("Dimension 2", HorizontalLengthPos, WP_S_F2_OE,WP_S_F2_IE) genDims.AddLinear("Dimension 3", HorizontalLengthPos2, WP_S_MP, WP_S_FLH, DimensionTypeEnum.kHorizontalDimensionType) genDims.AddLinear("Dimension 4", HorizontalLengthPos2, WP_S_MP, WP_GV_RH, DimensionTypeEnum.kHorizontalDimensionType) genDims.AddLinear("Dimension 5", VerticalLengthPos, WP_S_F2_OE, WP_S_FVCP, DimensionTypeEnum.kVerticalDimensionType) genDims.AddLinear("Dimension 6", VerticalLengthPos2, WP_S_F2_OE, F_B_TF, DimensionTypeEnum.kVerticalDimensionType) Case "WP_M_MP" '... Case "WP_L_MP" '... Case "WP_LM_MP" '... End Select Next
The dimensions may move from left to right, top to bottom of the view depending on how the user defines the form variables. That's why I'm listing them more than once. The only problem I'm having is with the following line:
For Each oPoint As WorkPoint In ThisDoc.Document.ComponentDefinition.WorkPoints
It gives this error:
I'm not that familiar with working with drawings but try replacing
For Each oPoint As WorkPoint In ThisDoc.Document.ComponentDefinition.WorkPoints
with
For Each oPoint As WorkPoint In ThisDoc.ModelDocument.ComponentDefinition.WorkPoints
This will get the document of the first view in the drawing, but I don't know if you have multiple assemblies in your drawing
Can't find what you're looking for? Ask the community or share your knowledge.