Inventor Customization

Reply
Distinguished Contributor
ADNpati
Posts: 125
Registered: ‎07-01-2012
Message 1 of 3 (157 Views)
Accepted Solution

Position of Part in idw

157 Views, 2 Replies
01-21-2013 05:50 PM

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 -

-------------------------------------------------------------------------------------
Distinguished Contributor
ADNpati
Posts: 125
Registered: ‎07-01-2012
Message 2 of 3 (138 Views)

Re: Position of Part in idw

01-24-2013 03:58 PM 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 -

-------------------------------------------------------------------------------------
Distinguished Contributor
ADNpati
Posts: 125
Registered: ‎07-01-2012
Message 3 of 3 (134 Views)

Re: Position of Part in idw

01-24-2013 04:38 PM in reply to: ADNpati

 

 

Here is the complete code, hope this will be helpful for somebody :smileyhappy: :smileyhappy: :smileyhappy:

 

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  :smileyhappy:  :smileyhappy:  :smileyhappy:

  

Mechanical Engineer
Inventor Applications Engineer

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

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

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube