×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

To Extract Circular Edges alone

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?
MySel.Add bdy
MySel.Search "Type=Topology.edge,sel"

Thanks in Advance.

RE: To Extract Circular Edges alone

(OP)
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.

RE: To Extract Circular Edges alone

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

RE: To Extract Circular Edges alone

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: To Extract Circular Edges alone

(OP)
Hi,

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

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

  • 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.

    RE: To Extract Circular Edges alone

    (OP)
    Sometimes dummy solids...Sometimes with features.

    RE: To Extract Circular Edges alone

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


    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 Sub 

    Another story with dumb solids....

    Regards
    Fernando

    https://picasaweb.google.com/102257836106335725208
    https://picasaweb.google.com/103462806772634246699...

    RE: To Extract Circular Edges alone

    (OP)
    Hi,

    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

    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 --> 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 SUb 

    Regards
    Fernando

    https://picasaweb.google.com/102257836106335725208
    https://picasaweb.google.com/103462806772634246699...

    RE: To Extract Circular Edges alone

    (OP)
    Hi Ferdo,

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

    Red Flag This Post

    Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

    Red Flag Submitted

    Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
    The Eng-Tips staff will check this out and take appropriate action.

    Reply To This Thread

    Posting in the Eng-Tips forums is a member-only feature.

    Click Here to join Eng-Tips and talk with other members!


    Resources