Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

To Extract Circular Edges alone

Status
Not open for further replies.

MskMsiva

Aerospace
Jan 6, 2015
15
US
Hi,

In a part, I need to extract the only the circular edges.
For that, I'm able to search and extract all the edges in a part. And then I'm able to check the extract geometrical type whether it is circle or not.

Is there any way to check for Circular Edges directly from topology instead searching all Edges?
MySel.Add bdy
MySel.Search "Type=Topology.edge,sel"​

Thanks in Advance.
 
Replies continue below

Recommended for you

Hi Frodo,

Thanks for ur time & suggestion.

MySel.Search "Type=Topology.edge,sel" & MySel.Search ("Type=Edge,Selection_BorderREdge") gave same result.
Both codes are selecting all the edges available in a partbody.

But I need to select the circular edges alone. Is there anyway to select the circular edges alone?

Right now, I am checking the edge as circular or not by following way.
1. Search for all edges
2. Extract those edges to a geometrical set
3. Check the Geometry Type of those Extracts from the geometrical set one by one.

Set HybridShapeExtract= hybridBody1.HybridShapes.Item(i)
Set HybridShapeExtractRef = prt.CreateReferenceFromObject(HybridShapeExtract)
intGeomType = objHSF.GetGeometricalFeatureType(HybridShapeExtractRef)
If intGeomType = 4 Then
Msgbox "Circular Edge"
End If
In this workaround, it takes lot of time in extracting all those of a part. The Partbody will have around 1000 to 1500 edges. In that circular edges will be around 100-150. If I am able to search for the circular edges alone, it willl reduce almost 1/10th of the time it consumes now.

Otherwise, in the below code, if I am able to pass the edge from partbody directly, instead of extracts, it will also helps in reducing the time. but I am anot able to do so.
Set HybridShapeExtractRef = prt.CreateReferenceFromObject(MySel.Item(i).Value)
MySel.Item(i).Value gives the edges from the partbody directly​

Thanks in Advance.
 
I was recently looking at a similar problem: we have a conical plate with hundreds of small cylinder on it. I want to fillet all of them.

Cylinders were added to the plate by Boolean operation, so by doing my search only on the Boolean Add I got only the edges I was looking for.

What i'm saying is that if your script need to be fast, maybe the user can help and use some best practice that would help the script.

Eric N.
indocti discant et ament meminisse periti
 
Hi,

Indeed, if I'm using your method to extract all edges it will take 3-4 minutes. Now, question is why do you want only round edges?

From your sample part I can think that you want to have points for holes/round centers. If you want this, time will be around half because you can skip the extraction of the edges.




Regards
Fernando

 
Hi,

I want to measure the distance between two 10mm diameter holes.
Fot this, following are the steps involved in the program.

[li]Searching & Selecting all the available edges[/li]
[li]Extracting all the edges[/li]
[li]Checking for the Circular Extract[/li]
[li]check for diameter of the circular extracts[/li]
[li]if circular extract diameter is 10mm, then create an axis for the circle[/li]
[li]finally measure the distance between all those axis created[/li]

For this, instead Searching all edges, if we have method to search & find circular edges alone,
Or​
If we are able to pass the edges from the partbody directly for checking whether it is Circular or not(as mentioned earlier in the Thread dated 12 Jan 15), then it will reduce the time consumption.

Thanks in advance.
 
Well, when you have features in the specification tree is easy, all you need is to identify holes, something like code bellow:


Code:
Language="VBSCRIPT"

Sub CATMain()

Dim  oPartDoc As PartDocument
Dim oBody As Body
Dim oHole As Hole
Dim i As Integer
Dim selection1 As Selection
Dim selection2 As Selection
Dim oHoleName As HoleName
Dim oHoleType As HoleType
'*******************************
CATIA.DisplayFileAlerts = False
	Dim Message, Style, Title, Response, MyString
	Message = ("You must have a temp folder in your C drive " &_
						""&(chr(13))&_
"	Do you want to continue ?")
	Style = vbYesNo + vbDefaultButton2    'Define buttons.
	Title = "Extract holes parameters to text file"   
	Response = MsgBox(Message, Style, Title)
		If Response = vbYes Then    ' User chose Yes.
   			 MyString = "Yes"
Else
    
   If Response = vbNo Then   
   			 MyString = "No"
Exit Sub

   End If
End If
'*************************************
Set document = CATIA.ActiveDocument

Set filesys = CATIA.FileSystem
crlf = chr(10)
filename = "c:\temp\Holes_parameters_of_"&document.Name&".txt"
if filesys.FileExists(filename) Then
filesys.DeleteFile(filename)
End If
Set file = filesys.CreateFile(filename,True)
Set stream = file.OpenAsTextStream("ForWriting")
err=0
'**************************************************************
iHoleInSelection = True
Set oPartDoc = CATIA.ActiveDocument
Set oBody = oPartDoc.Part.Bodies.Item("PartBody")

Set selection1 = oPartDoc.Selection
selection1.Search "(Name=PartBody* & CATPrtSearch.BodyFeature),all"

Set selection2 = oPartDoc.Selection
selection2.Search "Type=Hole,sel"

	stream.write("Crt_no"&";"&"Hole_Name"&";"&"Hole_Dia"&";"&"Hole_Type"&";x origin"&";y origin"&";z origin"&crlf) 'first line in output file

For i=1 To selection2.Count

Set oHole = selection2.Item(i).Value
Set oHoleName = selection2.Item(i).Value
Set oHoleType = selection2.Item(i).Value

'need a variant object in order to use method returning array
Dim vHole As Variant
Set vHole = oHole

'get the origin of the hole using the variant object
ReDim origin(2)
vHole.GetOrigin (origin)
	stream.write(i&";"&oHoleName.Name&";"&oHole.Diameter.Value&";"&oHole.Type&";x=" & origin(0) & ";y=" & origin(1) & ";z=" & origin(2)&crlf)
Next
MsgBox "Done"
End Sub

Another story with dumb solids....

Regards
Fernando

 
Hi,

Thanks a lot.
The difficulty is PartBody will have UserPattern/Rectangular Pattern of Holes. Sometimes Pocket Feature also used.

Thanks in Advance.
 
Hi,

I'll give you a small idea: check the type (like in bellow code, which, by the way, is not complete) for your selected elements. Hope this is enough for you. Test on different edges types and see what you need to "filter" in a loop (I suggest to use InStr condition). If you solve the problem for dummy solids is good for all.


Code:
Sub CATMain()

    Dim varFilter(0) As Variant
    Set objSel = CATIA.ActiveDocument.Selection
    objSel.Clear
    varFilter(0) = "AnyObject"
    strReturn = objSel.SelectElement2(varFilter, "Select any object in the active document…", False)

 Set objSelected = objSel.Item2(1).Value
Msgbox TypeName(objSelected)

End SUb

Regards
Fernando

 
Hi Ferdo,

Using your suggestion Msgbox TypeName(objSelected), I am able to reduce the time consumption.
Thanks a lot for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top