Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I want to get the thread dimension on the section as shown in the screenshot below.
To achieve this, based on the description, I need to:
Add True as a parameter for "Linear Diameter Type", but I don't understand what I should indicate as HoleOrThreadEdge in this case? Diameter ?? which line and how do that ??
My code looks like this:
Dim oSheet As Sheet = ThisApplication.ActiveDocument.ActiveSheet
Dim oView As DrawingView = Nothing
Dim oDoc As PartDocument
' Tworzenie kolekcji dla różnych typów otworów
Dim oColCounterBore As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oColCounterSink As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oColDrilled As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oColTapped As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
' Przeszukiwanie widoków, aby znaleźć oView o typie kDrawingSectionView
For Each tempView As DrawingView In oSheet.DrawingViews
If tempView.ViewType = kSectionDrawingViewType Then
oView = tempView
Exit For
End If
Next
If oView IsNot Nothing Then
oDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
' Przeszukiwanie wszystkich otworów w dokumencie części
For Each oHoleFeature As HoleFeature In oDoc.ComponentDefinition.Features.HoleFeatures
For Each oFace As Face In oHoleFeature.Faces
If oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then
For Each oCurve As DrawingCurve In oView.DrawingCurves
If oCurve.ModelGeometry Is oFace Then
' Najpierw sprawdzenie, czy otwór jest gwintowany
If oHoleFeature.Tapped Then
oColTapped.Add(oCurve)
Else
' Jeżeli nie jest gwintowany, klasyfikujemy według typu
Select Case oHoleFeature.HoleType
Case kCounterBoreHole
oColCounterBore.Add(oCurve)
Case kCounterSinkHole
oColCounterSink.Add(oCurve)
Case kDrilledHole
oColDrilled.Add(oCurve)
End Select
End If
End If
Next
End If
Next
Next
' Wyświetlenie liczby krawędzi gwintowanych
MsgBox("Liczba krawędzi gwintowanych: " & oColTapped.Count.ToString())
' Tutaj możesz kontynuować działania dla poszczególnych kolekcji, na przykład:
' - Wymiarowanie otworów kDrilledHole jak wcześniej.
' - Dodatkowe operacje dla innych typów otworów.
' Dodawanie notatki dla krawędzi gwintów
Dim i As Integer
For i = 1 To oColTapped.Count - 1 Step 2 ' -2, ponieważ korzystamy z i oraz i+1
Dim oThreadCurve As DrawingCurve = oColTapped.Item(i)
Dim nextThreadCurve As DrawingCurve = oColTapped.Item(i + 1)
Dim oIntent As GeometryIntent = oSheet.CreateGeometryIntent(oThreadCurve)
Dim oIntent12 As GeometryIntent = oSheet.CreateGeometryIntent(nextThreadCurve)
Dim notePosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d((oThreadCurve.MidPoint.X+nextThreadCurve.MidPoint.X)/2, oView.Top + 1)
Dim oNote As HoleThreadNote = oSheet.DrawingNotes.HoleThreadNotes.Add(notePosition, oIntent)
Next
' Dla przykładu, wymiarowanie otworów kDrilledHole:
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
If oColDrilled.Count >= 2 Then
For i = 1 To oColDrilled.Count - 1 Step 2
Dim oDim As DrawingDimension
Dim oIntent1 As GeometryIntent = oSheet.CreateGeometryIntent(oColDrilled(i))
Dim oIntent2 As GeometryIntent = oSheet.CreateGeometryIntent(oColDrilled(i + 1))
Dim oCurve1 As DrawingCurve = oColDrilled(i)
Dim oCurve2 As DrawingCurve = oColDrilled(i + 1)
Dim midPointX As Double = (oCurve1.StartPoint.X + oCurve1.EndPoint.X + oCurve2.StartPoint.X + oCurve2.EndPoint.X) / 4
Dim midPointY As Double = (oCurve1.StartPoint.Y + oCurve1.EndPoint.Y + oCurve2.StartPoint.Y + oCurve2.EndPoint.Y) / 4
Dim midPoint As Point2d = oTG.CreatePoint2d(midPointX, midPointY + 1)
oDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(midPoint, oIntent1, oIntent2, DimensionTypeEnum.kAlignedDimensionType)
Next
End If
Else
MsgBox("Nie znaleziono widoku przekroju.")
End If
And the result of its execution is either adding a dimension as shown below:
Or (when Linear Diameter Type = true Line66) an error as in the screenshot below:
Can someone tell me what I'm doing wrong and what should I change??
Regards,
ralfmja
Solved! Go to Solution.