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: 

Determine if DrawingCurve lies on section plane

4 REPLIES 4
Reply
Message 1 of 5
truscher
331 Views, 4 Replies

Determine if DrawingCurve lies on section plane

Hello all,

 

What I am trying to accomplish is the iterate through all the drawing curves in a section view and assign a new layer to those that do not lie on the section plane. We currently have to manually select each curve and assign those that are not part of the slice (or zero depth section) a layer called "Beyond" that changes the lineweight and color. Is there any way to tell if a particular drawing curve is on the section plane? we have thousands of autocad drawings for existing clients that were drawn with this convention, and it is killing us to try and re-create this in Inventor.

 

Best regards, and Thanks in advance,

 

Tom Ruscher

4 REPLIES 4
Message 2 of 5
YuhanZhang
in reply to: truscher

Maybe you can try below code to see if it satisfies you:

 

Sub Test()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oLayer As Layer
    Set oLayer = oDoc.StylesManager.Layers.Item("Beyond")
            
    Dim oSheet As Sheet
    Dim oView As DrawingView
    For Each oSheet In oDoc.Sheets
        For Each oView In oSheet.DrawingViews
            If oView.ViewType = kSectionDrawingViewType Then
                On Error Resume Next
                
                Dim oCurve As DrawingCurve
                For Each oCurve In oView.DrawingCurves
                    If Not (oCurve.ModelGeometry.Type = kFaceObject Or oCurve.ModelGeometry.Type = kFaceProxyObject) Then
                        oDoc.SelectSet.Select oCurve.Segments(1)
                        oCurve.Segments(1).Layer = oLayer
                    End If
                Next
            End If
        Next
    Next
        
End Sub

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 5
truscher
in reply to: YuhanZhang

Thank you very much for your help!

I am having some issues getting this to work unfortunately. First, i get the error "let and set statements are no longer supported". OK, I've seen this before and I eliminate the "set" from those lines as applicable. For example, "Set oDoc = ThisApplication.ActiveDocument" becomes "oDoc = ThisApplication.ActiveDocument". this resolves the first error. Then I get the error "Method Arguements must be inclosed in parentheses". I edit the the line "SyntaxEditor Code SnippetoDoc.SelectSet.Select oCurve.Segments(1) to read "oDoc.SelectSet.Select(oCurve.Segments(1))" and this resolves that error. Now the code runs, but it has no effect on the drawing views/curves that i can find. I have made sure that the "Beyond" layer exists and that it is Bright Red. After running the rule, have examined those curves that sould be affected, and have found then all to be on their original layer. the code is copied below:

 

SyntaxEditor Code Snippet

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oLayer As Layer
oLayer = oDoc.StylesManager.Layers.Item("Beyond")
        
Dim oSheet As Sheet
Dim oView As DrawingView
For Each oSheet In oDoc.Sheets
    For Each oView In oSheet.DrawingViews
        If oView.ViewType = kSectionDrawingViewType Then
            On Error Resume Next
            
            Dim oCurve As DrawingCurve
            For Each oCurve In oView.DrawingCurves
                If Not (oCurve.ModelGeometry.Type = kFaceObject Or oCurve.ModelGeometry.Type = kFaceProxyObject) Then
                    oDoc.SelectSet.Select(oCurve.Segments(1))
                    oCurve.Segments(1).Layer = oLayer
                End If
            Next
        End If
    Next
Next
Message 4 of 5
truscher
in reply to: truscher

Ok! after playing with this for a while i determined that it was not recongnizing the "kFaceProxyObject" And "kFaceObject" enums nad replaced them with their numbered equivalents and  made some progress. I then realized the it was only changing the layer frof the first segment of any DrawingCurve. An Additional For...Each loop based on the DrawingCurve.Segments.count property fixed that. I am left with ONE REMAINING PROBLEM. Any curve that represents the profile of a curved object, for example the "sides" of a cylinder (not the top and bottom)  are not changed. See screen shot below (The profile of the legs should be light gray, not just those edges that represent planar edges):

CaptureSection.JPG

 

Does this Invalidate this approach? Is there some other method for identifying these edges? I hope we can find one as it would really be disapointing to get this close and not succeed! The revisewd code is pasted below:

SyntaxEditor Code Snippet

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oLayer As Layer
oLayer = oDoc.StylesManager.Layers.Item("Beyond")
        
Dim oSheet As Sheet
Dim oView As DrawingView
For Each oSheet In oDoc.Sheets
    For Each oView In oSheet.DrawingViews
        If oView.ViewType = 10503 Then
            On Error Resume Next
            
            Dim oCurve As DrawingCurve
            For Each oCurve In oView.DrawingCurves

                If Not (oCurve.ModelGeometry.Type = 67119408 Or oCurve.ModelGeometry.Type = 67119520) Then
'                    oDoc.SelectSet.Select(oCurve.Segments(1))
                    Dim i As Integer
                    i = oCurve.Segments.Count

                    For n=1 To i
                        oCurve.Segments(n).Layer = oLayer
                        oCurve.Layer = oLayer
                    Next
                End If
            Next
        End If
    Next
Next

 

Thanks Again,

Tom

Message 5 of 5
YuhanZhang
in reply to: truscher

Hi Tom,

 

The sample I created is VBA sample, you can run it in Invnetor VBA editor(use Alt+F11 to start the VBA Editor, and copy the code to a module, run it). Now I checked that code and yes as you found there would be some exceptional drawing curves that we can't recognize, i.e. the drawing curves from Face but not at the zero-depth. I checked other properties for them but no lucky, the way we can do maybe log a wish so if we can expose new APIs for the section view hatch that would be easy to recognize the drawing curves which are boundaries of a hatch or not.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report