Set the dimension position

Set the dimension position

kv5053545
Advocate Advocate
505 Views
4 Replies
Message 1 of 5

Set the dimension position

kv5053545
Advocate
Advocate

I have a drawing that has several occurrences within it and I would like to dimension it but when my set is bigger the dimensions get messed up, I don't know if it is possible to differentiate the sides of my set for example the top, bottom, right and left side, to define the position of the dimensions depending on where it is located.

0 Likes
506 Views
4 Replies
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

Hi @kv5053545 

Can you share an image of how the dimensions are changing when model size changes? Are you using code to add the dimensions if so please attach the code. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 5

kv5053545
Advocate
Advocate

hi @A.Acheson,

this is the code i've been using, I still can't figure out how to know which side the occurrence is on (right,left,up or down), in both drawings i'm using the same code only one has more walls(occurrences) than the other one.

Dim drawingDoc As DrawingDocument = ThisApplication.ActiveDocument
' Loop through each sheet in the drawing document
For Each sheet As Sheet In drawingDoc.Sheets
	' Loop through each view on the sheet
For Each view As DrawingView In Sheet.DrawingViews
    If View.name = "VIEW1" Then
        ' Check if the view is an assembly view
        ' Get the assembly document for the view
        Dim asmDoc As AssemblyDocument = View.ReferencedDocumentDescriptor.ReferencedDocument

        ' [Loop through each assembly component
        For Each comp As ComponentOccurrence In asmDoc.ComponentDefinition.Occurrences
            Dim Componente = comp.Name 
            Dim BuscarWalls As String = "Wall"
            If Componente.Contains(BuscarWalls) = True Then
				
                ' Add a dimension to the component if the component name contains "Wall"
               Dim ShGeneral = ThisDrawing.Sheets.ItemByName("General:1") 
               Dim genDims = ShGeneral.DrawingDimensions.GeneralDimensions
               Dim VIEW1 = ShGeneral.DrawingViews.ItemByName("VIEW1") 
			   Dim WPl_Wall_FlangeLeft = VIEW1.GetIntent(comp.Name,"WPl_Wall-FlangeLeft")
               Dim WPl_Wall_FlangeRight = VIEW1.GetIntent(comp.Name, "WPl_Wall-FlangeRight")

 
''[Find a way to set the dimension depending on where the coordinate is located
''[Declare variables for the dimension position
Dim oMatrix As Matrix = comp.Transformation
Dim x As Double = oMatrix.Cell(1, 4)
Dim y As Double = oMatrix.Cell(2, 4)
Dim z As Double = oMatrix.Cell(3, 4)

Dim dimX As Double
Dim dimY As Double 
 If x < 0 And y < 0 And z < 0 Then 
    dimX = 1.10
	dimY = -0.02
	
Else If x > 0 And y < 0 And z < 0 Then  
   dimX = -0.03
	dimY = 1
	
Else If x > 0 And z > 0 And y < 0 Then 
	dimX = 0.07
	dimY = 1.02
	
Else If z > 0 And x < 0 And y < 0  Then
	dimX = 1.03 
	dimY = 0

End If

                Dim linDim1 = genDims.AddLinear("Width_" & Componente, VIEW1.SheetPoint(dimX, dimY), WPl_Wall_FlangeLeft, WPl_Wall_FlangeRight)
          
            End If
        Next
    End If
    Next
   Next

 image.pngimage.png

0 Likes
Message 4 of 5

A.Acheson
Mentor
Mentor

Hi @kv5053545 

You can try center the text firstly and see how that works out. 

Dim dim1 As LinearGeneralDimension = '............
dim1.CenterText

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 5

kv5053545
Advocate
Advocate
If the text is centered they are still placed on top of the other dimensions, I don't know why the coordinates change and with them the dimensions instead of being on the right are shifted to the left and the lower dimensions are shifted to the top.
0 Likes