Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Count visible selected type of drawing curve segment by any selectset

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
716 Views, 8 Replies

Count visible selected type of drawing curve segment by any selectset

Hi...

I want to count visible selected type of drawing curve segment by any selectset is activate in drawing view...

I get difficulties to  get the drawing view name (ex: "VIEW16") by activate selectset a drawing curve segment in that view...

The counting seem not found the correct answer... as below example... the part is actually having 2 size of fillet...

"Fillet1" x3 and Fillet2" x2 ... "Fillet1" visible count should be 2 in "VIWE16" but the result only count 1...

 

VBa.

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSSet As SelectSet
Set oSSet = oDrawDoc.SelectSet
Dim oDwgCurveSegment As DrawingCurveSegment
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oView As DrawingView
Set oView = oSheet.DrawingViews.Item(1)
Dim i As Integer
For i = 1 To oView.DrawingCurves.Count
If oView.Name = "VIEW16" ThenFor Each oDwgCurveSegment In oView.DrawingCurves.Item(i).Segments
If oDwgCurveSegment.GeometryType = kCircularArcCurve2d Then
i = i + 1
MsgBox "kCircularArcCurve2d[" & i & "]"
End If
Next
End If

8 REPLIES 8
Message 2 of 9
HideoYamada
in reply to: Anonymous

Hi,

 

I don't understand exactly what you want to do, but I have just rewritten your code.

 

Option Explicit

Sub test()
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    Dim oSSet As SelectSet
    Set oSSet = oDrawDoc.SelectSet
    Dim oDwgCurveSegment As DrawingCurveSegment
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    Dim oView As DrawingView
    Set oView = oSheet.DrawingViews.Item(1)
    
    If oView.Name = "VIEW16" Then
        Dim i As Integer
        Dim oDrawingCurve As DrawingCurve
        For Each oDrawingCurve In oView.DrawingCurves
            For Each oDwgCurveSegment In oDrawingCurve.Segments
                If oDwgCurveSegment.GeometryType = kCircularArcCurve2d Then
                    i = i + 1
                    MsgBox "kCircularArcCurve2d[" & i & "]"
                End If
            Next oDwgCurveSegment
        Next oDrawingCurve
    End If
End Sub

 

Has this code approached what you want to do?

 

=====

Freeradical

 Hideo Yamada

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
Message 3 of 9
Anonymous
in reply to: HideoYamada

Hi.

Please use my e-mail for this conversation.

The code is for my testing to approach what I actually need.

[ I need to count the visible "Fillet?" by one of it curve segments
selectset in it view (ex:VIEW16). To get the name VIEW16 by curve segment
selectset also I still struggle and not yet figure out how.]
Message 4 of 9
Anonymous
in reply to: HideoYamada

Hi…

Please use my e-mail for this conversation…

The code is for my testing to approach what I actually need…

[ I need to count the visible “Fillet?” by one of it curve segments selectset in it view (ex:VIEW16)… To get the name VIEW16 by curve segment selectset also I still struggle and not yet figure out how…]

Message 5 of 9
HideoYamada
in reply to: Anonymous

Hi,

 


@Anonymous wrote:

Please use my e-mail for this conversation…

O.K. Send the mail or private message to me freely.

 


To get the name VIEW16 by curve segment selectset also I still struggle and not yet figure out how…
Sub test2()
    Dim oDrawingCurveSegment As DrawingCurveSegment
    Dim oDrawingView As DrawingView
    
    Set oDrawingCurveSegment = ThisApplication.ActiveDocument.SelectSet(1)
    Set oDrawingView = oDrawingCurveSegment.Parent.Parent
    
    Debug.Print oDrawingView.Name
End Sub

The parent of the parent of the DrawingCurveSegment is DrawingView.

 

=====

Freeradical

 Hideo Yamada

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
Message 6 of 9
Anonymous
in reply to: HideoYamada

Thanks,

I manage to get the drawing view name as your suggest... but I still having error for below sample to get the counting result as I need ...

 

Public Sub FilletLeader()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSSet As SelectSet
Dim oDwgCurveSegment As DrawingCurveSegment
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oView As DrawingView
Dim oFeatureName As String
Dim oFace As Face
Dim i As Integer
Dim RadiusDim As RadiusGeneralDimension
Set oSSet = oDrawDoc.SelectSet
Set RadiusDim = oSSet(1)
Set oView = RadiusDim.Intent.Geometry.Parent
Set oDwgCurveSegment = RadiusDim.Intent.Geometry.Segments(1)
Set oFace = RadiusDim.Intent.Geometry.ModelGeometry.Faces(2)
oFeatureName = oFace.CreatedByFeature.Name
For Each oDwgCurveSegment In oView
If oFace.CreatedByFeature.Faces.Item.CreatedByFeature.Name = oFeatureName Then
i = i + 1
MsgBox oFeatureName & " = " & i
End If
Next

 

 

 
Message 7 of 9
HideoYamada
in reply to: Anonymous

Hi,

 

This code will count the fillet curves that the feature is selected by the radius dimension and are shown as an arc in the view.

 

Public Sub FilletLeader()
    '
    ' Check the condition and initialize the values.
    '
    If Not TypeOf ThisApplication.ActiveDocument Is DrawingDocument Then Exit Sub
    Dim oDrawDoc As DrawingDocument: Set oDrawDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet: Set oSheet = oDrawDoc.ActiveSheet
    If oSheet Is Nothing Then Exit Sub
    
    Dim oSSet As SelectSet: Set oSSet = oDrawDoc.SelectSet
    If oSSet.count < 1 Then Exit Sub
    
    If Not TypeOf oSSet(1) Is RadiusGeneralDimension Then Exit Sub
    Dim oRadiusDim As RadiusGeneralDimension: Set oRadiusDim = oSSet(1)
    
    Dim oFilletFeature As FilletFeature
    Dim oFace As Face
    For Each oFace In oRadiusDim.Intent.Geometry.ModelGeometry.Faces
        If TypeOf oFace.CreatedByFeature Is FilletFeature Then
            Set oFilletFeature = oFace.CreatedByFeature
            Exit For
        End If
    Next oFace
    If oFilletFeature Is Nothing Then Exit Sub
    
'    Debug.Print oFilletFeature.Name
    
    '
    ' Prepare for counting the fillet edges
    '
    Dim oView As DrawingView: Set oView = oRadiusDim.Intent.Geometry.Parent
    
    Dim NofFilletFaces As Integer
    NofFilletFaces = oFilletFeature.Faces.count
    
    Dim counted() As Boolean: ReDim counted(NofFilletFaces)
    Dim count As Integer
    Dim i As Integer
    
    
    '
    ' Count fillet edges.
    '
    Dim oDwgCurve As DrawingCurve
    For Each oDwgCurve In oView.DrawingCurves
        ' Only count if the edge is shown as an arc.
        If TypeOf oDwgCurve.Segments(1).Geometry Is Arc2d Then
            For Each oFace In oDwgCurve.ModelGeometry.Faces
                If oFace.CreatedByFeature Is oFilletFeature Then
                    ' Only count one time for each fillet face.
                    For i = 1 To NofFilletFaces
                        If oFilletFeature.Faces(i) = oFace And (Not counted(i)) Then
                            counted(i) = True
                            count = count + 1
                            Exit For
                        End If
                    Next i
                End If
                If count = NofFilletFaces Then Exit For
            Next oFace
        End If
        If count = NofFilletFaces Then Exit For
    Next oDwgCurve
        
    Debug.Print count
End Sub

 

I think that this code works as you want.

 

=====

Freeradical

 Hideo Yamada

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
Message 8 of 9
Anonymous
in reply to: HideoYamada

Thank you so much... May be I still need your help next time...

Message 9 of 9
Anonymous
in reply to: HideoYamada

Hi... I try the same method for count the "Chamfer1" in a View.... but can't figure out the curve segment like Fillet... Anything you can do about it...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report