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: 

Position of Part in idw

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ADNpati
388 Views, 2 Replies

Position of Part in idw

Hi,

 

How to get postion of faces of part when place on idw drawing file???

 

Do we need to use (ThisApplication.MeasureTools.GetMinimumDistance(oTG.CreatePoint2d(0, 0), oFa.PointOnFace)????

 


If we use that we will get distance  but how to get face postion on idw. do we need to use edges?? or lines???

 

positiononidw.JPG

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
2 REPLIES 2
Message 2 of 3
ADNpati
in reply to: ADNpati

I found way again by myself.....

 

Using ModelToSheetSpace with drawingview we can get reference to anything from Model i.e., 3D Enviroment to sheet space Enviroment.

 

working on code and will post you in 10 mins... cheers

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
Message 3 of 3
ADNpati
in reply to: ADNpati

 

 

Here is the complete code, hope this will be helpful for somebody Smiley Happy Smiley Happy Smiley Happy

 

Option Explicit
Sub FaceRecognitiononIDW()


    Dim oDrawingDoc As DrawingDocument
    Set oDrawingDoc = ThisApplication.ActiveDocument
    Dim oDef As ComponentDefinition
    
    Dim itemCnt As Integer
    itemCnt = 0
    
    Dim oView As DrawingView
    Set oView = oDrawingDoc.ActiveSheet.DrawingViews(1)
    
    Dim oDoc As Document
    Set oDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    
    Dim oPartDoc  As Document
    Dim oRrubberPart As PartDocument
    Dim oAllRef As DocumentsEnumerator
    Dim occ As ComponentOccurrence
    Dim occDef As ComponentDefinition
    Dim oTextBox As TextBox
    Dim oPartCompDef As PartComponentDefinition
    Dim oSurfBody As SurfaceBody
    Dim oFa As face
    
    ' Set a reference to the active sheet.
    Dim oActiveSheet As Sheet
    Set oActiveSheet = oDrawingDoc.ActiveSheet
    
    For Each occ In oDoc.ComponentDefinition.occurrences
    If occ.DefinitionDocumentType = kPartDocumentObject Then
        If occ.SurfaceBodies.count <> 0 Then
            Set oPartDoc = occ.Definition.Document
            Set occDef = oPartDoc.ComponentDefinition
            Set oSurfBody = occDef.SurfaceBodies(1)
            Set oPartCompDef = occ.Definition
            For Each oFa In oSurfBody.Faces
                itemCnt = itemCnt + 1
                If oFa.SurfaceType = kPlaneSurface Then
                ' Getting a planar surface face above
                ' ground level and face not connected
                ' to any other face
                    If oFa.TangentiallyConnectedFaces.count = 0 Then
                        If oFa.PointOnFace.Z <> "0" Then
                            If ThisApplication.MeasureTools.GetAngle(oFa, occ.Definition.WorkPlanes(3)) = "0" Then
                                Dim oFaProxy As FaceProxy
                                Call occ.CreateGeometryProxy(oFa, oFaProxy)
                                ' Get the point of the sketch
                                Dim oMidPoint As Point2d
                                Set oMidPoint = oView.ModelToSheetSpace(oFaProxy.PointOnFace)
                                
                                ' Set a reference to the TransientGeometry object.
                                Dim oTG As TransientGeometry
                                Set oTG = ThisApplication.TransientGeometry
                                
                                Dim oLeaderPoints As ObjectCollection
                                Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
                                
                                ' Create a few leader points.
                                Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.x, oMidPoint.y))
                                Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.x + 0.5, oMidPoint.y + 0.5))
                                
                                ' Create text with simple string as input. Since this doesn't use
                                ' any text overrides, it will default to the active text style.
                                Dim sText As String
                                sText = "API Leader Note"
                                
                                Dim oLeaderNote As LeaderNote
                                Set oLeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, sText)
                                
                                ' Insert a node.
                                Dim oFirstNode As LeaderNode
                                Set oFirstNode = oLeaderNote.Leader.RootNode.ChildNodes.Item(1)
                            End If
                        End If
                    End If
                End If
            Next
        End If
    End If
    Next
End Sub

 If found useful give some kudos  Smiley Happy  Smiley Happy  Smiley Happy

  

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------

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

Post to forums  

Autodesk Design & Make Report