Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
frank_schalla
477 Views, 6 Replies

Find out the primitive shape of a part

Hi all

I must find out for laser cutting parts if a part is
Square / Rectangle / Round

I have tried many things to find this.

Any ideas from your site ?

WCrihfield
in reply to: frank_schalla

Hi @frank_schalla.  You may have to share a lot more details than that so we can better understand the situation and offer better solutions.  Are you looking for an iLogic rule based solution?  If so, will it be ran on an active part document, an assembly document, or a drawing document?  Are the parts in question all going to be sheet metal parts, or are they just regular parts, or are some regular parts and some sheet metal parts?  Will all the parts be one of the 3 listed shapes (square, rectangle, or round), or are some other shapes?  What type of feedback or results are you expecting from the test (pop-up message, write something to an iProperty/Parameter, run a secondary process on it, etc.)?  If you wand to run a rule on an assembly, should it just work on the top level components, or should it dig down into sub assemblies, and should it process any of the sub assemblies themselves, or just the parts?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

petr.meduna
in reply to: frank_schalla

Hi,

 

try this rule:

Dim part As PartDocument = ThisApplication.ActiveDocument
Dim comp As PartComponentDefinition = part.ComponentDefinition
Dim squareEdges As Integer = 4
Dim roundEdge As Integer = 1
Dim areaList As New ArrayList
Dim oArea As Double
Dim oEdge1 As Edge, oEdge2 As Edge
Dim mt As MeasureTools = ThisApplication.MeasureTools
Dim length1 As Double, length2 As Double

For Each oFace As Face In comp.SurfaceBodies.Item(1).Faces
	areaList.Add(oFace.Evaluator.Area & "=" & oFace.TransientKey)
Next
areaList.Sort()
Dim oSplit() As String = Split(areaList.Item(areaList.Count-1), "=")
For Each oFace As Face In comp.SurfaceBodies.Item(1).Faces
	If oFace.TransientKey = oSplit(1) Then
		If oFace.Edges.Count = roundEdge Then
			MessageBox.Show("Part is round.")
			Exit Sub
		ElseIf oFace.Edges.Count = squareEdges Then
			oEdge1 = oFace.Edges.Item(1)
			oEdge2 = oFace.Edges.Item(2)
			length1 = Round(mt.GetMinimumDistance(oEdge1.StartVertex, oEdge1.StopVertex), 3)
			length2 = Round(mt.GetMinimumDistance(oEdge2.StartVertex, oEdge2.StopVertex), 3)
			If length1 = length2 Then
				MessageBox.Show("Part is square.")
				Exit Sub
			ElseIf Not length1 = length2
				MessageBox.Show("Part is rectangle.")
				Exit Sub
			End If
		Else
			MessageBox.Show("Part with another shape.")
			Exit Sub
		End If
	End If
Next
d_stockinger
in reply to: petr.meduna

Hello,

 

did you also find a solution for normal Parts and Assemblies to detect 

  • Round
  • Square
  • Rectangle shape?

With the Bounding Box you can detect Square or Rectangle Shapes, but whats about round?

frank_schalla
in reply to: WCrihfield

Hello

Thank’s for all the answers.

Here are the more deeply info’s.

 

Main Goal

Inside my Addin the user has to select a Teamcenter related underlying RAW MATERIAL.

This list is filtered by the form of the part.

 

I find the exact size all done.

My problem is a size of 50x50 can be a round ore a rectangular one.

The list inside the attachments must be filtered if it’s round or square.

That is the reason why I try to find a way (at the start) to filter if the primitive is
ROUND/RECTANGLE or SQUARE

 

WCrihfield
in reply to: frank_schalla

Hi @frank_schalla.  I have an idea for you to consider for your project going forward.  Since the designer of these parts will know whether the part will be or is a certain primitive shape, the designer could find a way to record this designation within the model file when they create the model files, so that you will not have to go back and inspect the physical geometry of the model by code in an attempt to figure this out later.  You could create something like a multi-value Text type user parameter with those three possible values in it (square, rectangle, circle).  You could use one of the standard iProperties that you currently do not use, or create a custom iProperty with a name you can standardize across all model files, and assign one of those keywords as its value.  You could create an Attribute within an AttributeSets of the Document.AttributeSets property, again with a standardized name, and set one of those keywords as its value.  There are lots of ideas like this for somehow marking or designating a model document so that it can be very quickly and easily identified later.  I know this doesn't address model files that already exist, but maybe you can mark those existing model files in this way as you encounter or work with them and identify them along the way.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

frank_schalla
in reply to: WCrihfield

Thanks for this idea

My hope to get something out of the BREP reps ?