To Extract Circular Edges alone
To Extract Circular Edges alone
(OP)
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?
Thanks in Advance.
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"
MySel.Search "Type=Topology.edge,sel"
Thanks in Advance.





RE: To Extract Circular Edges alone
Maybe you can use
MySel.Search ("Type=Edge,Selection_BorderREdge")
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: To Extract Circular Edges alone
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)
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.
MySel.Item(i).Value gives the edges from the partbody directly
Thanks in Advance.
RE: To Extract Circular Edges alone
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: To Extract Circular Edges alone
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.
indocti discant et ament meminisse periti
RE: To Extract Circular Edges alone
Please find the sample part. Change Sample.txt to sample.catpart.
Time taken for extraction is around 3-4 mins.
Thanks in advance.
RE: To Extract Circular Edges alone
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
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: To Extract Circular Edges alone
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: To Extract Circular Edges alone
I want to measure the distance between two 10mm diameter holes.
Fot this, following are the steps involved in the program.
For this, instead Searching all edges, if we have method to search & find circular edges alone,
Thanks in advance.
RE: To Extract Circular Edges alone
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: To Extract Circular Edges alone
RE: To Extract Circular Edges alone
CODE --> CATScript
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 SubAnother story with dumb solids....
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: To Extract Circular Edges alone
Thanks a lot.
The difficulty is PartBody will have UserPattern/Rectangular Pattern of Holes. Sometimes Pocket Feature also used.
Thanks in Advance.
RE: To Extract Circular Edges alone
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 --> CATScript
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 SUbRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: To Extract Circular Edges alone
Using your suggestion Msgbox TypeName(objSelected), I am able to reduce the time consumption.
Thanks a lot for your time.