Lenght of profile

Lenght of profile

Leonardo_Czuy
Advocate Advocate
225 Views
4 Replies
Message 1 of 5

Lenght of profile

Leonardo_Czuy
Advocate
Advocate

Hello, 


I am attempting to retrieve the length of a profile, but when I try to do this with a small profile, such as UNP 160 with a length of 100mm. However, the code retrieves 160mm instead of the correct 100mm. Any ideas on how to disregard the 160mm and obtain the accurate 100mm value?

Leonardo_Czuy_1-1705944983827.png

 

Sub Main()
    Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oDoc As Inventor.Document

    Dim caminhoArquivo As String = "C:\Users\Leonardo Souza\Desktop\Inventor-iLogic\zTest.txt"

    Dim arquivo As System.IO.StreamWriter
    arquivo = My.Computer.FileSystem.OpenTextFileWriter(caminhoArquivo, False)

	For Each oDoc In asmDoc.AllReferencedDocuments
        ' Se for arquivo de Montagem Ignora
        If oDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
			Continue For
		End If
		
        If TypeOf oDoc.ComponentDefinition Is SheetMetalComponentDefinition Then
            Continue For
        End If

        Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition

        Dim oSolid As SurfaceBody
        Dim oLength As Double
            
        If oDef.SurfaceBodies.Count > 0 Then
            oSolid = oDef.SurfaceBodies.Item(1)
            oLength = Round(MaxOfMany(oSolid.OrientedMinimumRangeBox.DirectionOne.Length, _
                                    oSolid.OrientedMinimumRangeBox.DirectionTwo.Length, _
                                    oSolid.OrientedMinimumRangeBox.DirectionThree.Length) * 10, 1)
            t = oDef.Parameters.Item("G_L")

            arquivo.WriteLine(oDoc.DisplayName & " / " & oLength & " / " & t.Value * 10)
            
        End If
	Next
    arquivo.Close()
End Sub

 

0 Likes
226 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @Leonardo_Czuy.  Just curious, but I assume that the Parameter named "G_L" is the one for the length of that part, which is why you are checking it against the other measurement obtained.  So if you already know what parameter is being used for the length of the part, then why try to get the profile's length through the SurfaceBody.OrientedMinimumRangeBox property direction lengths?  When he part's length is a smaller value than one of the 2D profile sketch's dimensions, then the length of the part will obviously no longer be the 'Max' of all 3 distances, causing this type of problem.  And we also do not know which of the 3 overall dimensions will be its length, without first knowing that we are inspecting a basic part that was created by extruding a 2D sketch to its final length, then we would also need to know the 2D profile size of that part, so we can compare those 2 sizes against the resulting 3 sizes we get from the range box.  You would either need to be very familiar with all the models involved, or maybe include some additional information within the iProperties of the models you are inspecting, for just such purposes.  But if you are dealing with Content Center models, like I suspect, then those model files are usually ReadOnly, preventing you from changing or editing the iProperties in those model files.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

Leonardo_Czuy
Advocate
Advocate

Hello @WCrihfield,

SomeTimes G_L dont representation exactly in Model, because this i am trying to get from 3 overall dimensions.

Leonardo_Czuy_0-1705949841544.png

 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

The part in that last image appears to have angled ends on it.  That would definitely be more complicated to inspect for length than a simple, straight extruded profile would.  I had an alternative process in mind for the simple case, such as the part in the first image, but that alternative process would likely not be good enough for checking the second part.  I was going to suggest checking if the part only has one ExtrudeFeature, and if so, inspect that ExtrudeFeature further to get the length you want.  But even that process can be a bit complicated too, because there are multiple ways to define the extents of an extrude feature.  If it was a simple, one direction, distance type extrude, then that would be the easiest to get (DistanceExtent.Distance).  But there can be 2 directions, and the two directions can be unequal distances, or there can be 'From' and 'To' or between type aspects of it, instead of typed in distances.  Because of that, there are several derived types of feature extents, some of which do not offer a simple distance type property to get that value from.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

abdullah_elq
Advocate
Advocate

@Leonardo_Czuy check out these guys: https://draftaid.io/

 

Their tool is really good at dealing with extrusions, even really complex one.

0 Likes