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!

Extract special coordinates

Status
Not open for further replies.

AtomicNico

Nuclear
May 10, 2016
62
FR
Hello, that's me again but for another question

I got some pipes where I need to extract some special coordinates.
I'm attaching a file to show what kind of pipes I have.
For the T, I need to extract the origin coordinates, the end coordinates and the branch coordinates.
For the other one, I would like to extract the intersection of the neutral fibers.

How can I make that?

Moreover, how can I extract the diameter?

Best regards
 
 http://files.engineering.com/getfile.aspx?folder=6fde1b02-f6bf-41b4-a89b-0d8be11d2271&file=coude-iso-3d-90-roule-soude-inox-304-l-316-5611-dmod1.jpg
Replies continue below

Recommended for you

I'm not searching for free job made by another person, I'm just trying to have an idea of how doing that (e.g. like putting nodes on each part) and the type of command I have to write (e.g. product.Coordinates.GetOrigin MyVPOrigin)
I can write the rest by myself
 
you have to find those point in the part (I guess they are published) and get their XYZ and you might have to combine this with part position in order to get those point in root coordinate system and not just the part system.

Eric N.
indocti discant et ament meminisse periti
 
Is it possible to extract points whose are in the sketcher mode through a macro?
 
if the point is in construction mode i dont know... if in standard mode it should be ok as a vertex.

Eric N.
indocti discant et ament meminisse periti
 
itsmyjob said:
you have to find those point in the part (I guess they are published)

I think the publication isn't automatic but made by the person who design the sketch, so if the person doesn't do it, that won't work I think.

Ok tesak, so it will be something like
Dim oPoint As GeometricElement
Sub GetCoordinates( CATSafeArrayVariant oPoint) ?
 
Not exactly, try something like this:

Code:
Sub GetAllSketchPoints()
    Dim doc, mySketches, mySketch, elements
    
    Set doc = CATIA.ActiveDocument
    Set mySketches = doc.Part.MainBody.Sketches
    Set mySketch = mySketches.Item(1)
    Set elements = mySketch.GeometricElements
    
    For i = 1 To elements.Count
        If elements.Item(i).GeometricType = catGeoTypePoint2D Then
            Dim coords(1)
            
            elements.Item(i).GetCoordinates coords
            MsgBox "Point coordinates are: " & coords(0) & "," & coords(1)
        End If
    Next
End Sub

This snippet will show you coordinates of all points in sketch.

Tesak
- Curved text for Catia V5
 
Actually I have something like that
download.aspx

And the global assembly has 250+ pieces, so I need to extract the information I need, no more. So I need those specific points of origin, end and branch.

The problem is: I don't know if the points in the sketcher will be in the same organized way from one part to another.

I thought about it after some tries and now I think the ideal solution would be to work on the surfaces directly.
I looked on the Automation file and I found some nice commands like GetOrigin, GetCenter, or GetOrigin, but on a part like this, I don't know how to organize my code
 
Hi,

Maybe is better to give more details...how are those pipe parts done? Ribs with curves (for guide curve and profile) or curves/lines in 3D and sketches for profile) or in another way (imported solids without history)?

Even better, few samples uploaded here could make us understand how your assy is done. Is it CATIA v5 or v6?

Regards
Fernando

- Romania
- EU
 
If the structure of the part is always different and unique, such a task is almost impossible to automate and it always requires some manual input. If you have more assemblies like this sharing same parts then try perhaps to create this points manually, expose them and then you can get them whenever you need.

Tesak
- Curved text for Catia V5
 
ferdo said:
Maybe is better to give more details...how are those pipe parts done? Ribs with curves (for guide curve and profile) or curves/lines in 3D and sketches for profile) or in another way (imported solids without history)?

Even better, few samples uploaded here could make us understand how your assy is done. Is it CATIA v5 or v6?
I'll upload some of the pieces as you asked.
It is Catia V5-6R2014

tesak said:
If the structure of the part is always different and unique, such a task is almost impossible to automate and it always requires some manual input. If you have more assemblies like this sharing same parts then try perhaps to create this points manually, expose them and then you can get them whenever you need.
I'm not saying that it will always be different and unique, I'm just considering the case where it would be the worst.

I started to write a code as a test to extract centers of faces in my solid, but it still is on "beta testing" because I picked some commands everywhere and put them together to have my own code
Code:
Sub CATMain()

Dim InputObjectType(0)
Set Document = CATIA.ActiveDocument
 Set Selection = Document.Selection

 'We propose to the user that he select the face to extract coordinates
 InputObjectType(0)="Face"
 Status=Selection.SelectElement2(InputObjectType,"Select the face",true)
 if (Status = "cancel") then Exit Sub
 Set FaceToDraft = Selection.Item(1).Value
 Selection.Clear
 
 Dim Coordinates(2)
 FaceToDraft.GetCOG Coordinates

 MsgBox "x = " & Coordinates(0) & " ; y = " & Coordinates(1) & " ; z = " & Coordinates(2)

End Sub
(Code not working atm)
As you can see, this is mainly the code you can find in the Automation about PlanarFace, but I'm trying to implement code that will allow me to select automatically the faces and give me the center in an Excel File.
Moreover, I'm trying to make a loop that will select the part once at the time

Edit: Parts uploaded
 
I'm still thinking about the ways of doing such a job.
Could it be possible if the macro automatically identified points in the center of Planar faces, and then at each point I would make a GetFirstPointCoordinates?
It is really frustrating that commands like GetCenter work only on circle or sphere and not on Planar faces... [shadessad]
 
If you select circular edge, you can measure circle center coordinates this way:

Code:
Sub GetCenterPoint()
    Dim doc, sel, spa, ref, measurable
    
    Set doc = CATIA.ActiveDocument
    Set sel = doc.Selection
    Set spa = doc.GetWorkbench("SPAWorkbench")
    Set ref = sel.Item(1).Reference
    Set measurable = spa.GetMeasurable(ref)
    
    Dim coords(2)
    measurable.GetCenter coords
    
    MsgBox "Center coordinates are: " & coords(0) & "," & coords(1) & "," & coords(2)
End Sub

To run this example you have to preselect a circular edge on your part.

Tesak
- Curved text for Catia V5
 
you working backward... don't look at some code and say how can i use this? define the logic you want first then say: what is the code to get this?

the script you're doing is big. if you don't use a smart logic it will be a mess.

I guess you already have the output of your script: create file with proper information / format from CATIA to other tubing app.

now define the input: will it be a product of part with dumb solid, solid from tubing workbench, just tubing run, user created tube geometry... define what is in scope what is not.

then process with logic from geometry to get the info then from info to output format. The logic to extract the info will be different from one input (tubing run) to another (user created geometry). Try to have the least interaction with the user, make the application smart : why would you ask the user to select a solid if there is only one in the file? (the logic definition would help you define smart opportunities).

for your standard parts I would search for edges in the solid then keep only circle one and get circle center, from that you can also get the normal direction if you need.

for the tube, if you use the tubing workbench and have the run, you should be able to get the points (and bend radius) from the run. If you don't have the run but used the tubing workbench you should be able to identify the sketch that define the tube center line and then get info from vertices or edges regarding the info you need.

When a code is playing with selection is might be wise to prevent user from interacting... pop up a modal form that eventually inform the user about the process evolution : found tube name xxx, processing points, found standard part name yyy, processing points... this could also help you !


Eric N.
indocti discant et ament meminisse periti
 
Ok, so just to see if it could work, I adapted the code tesak gave me above for a selection on my part and it doesn't work because "This object does not handle this property or method: EdgeToCenter.GetCenter". So I'm guessing I have a problem in my Dim or about the method (probably the selection method).
Here's my script
Code:
Sub CATMain()

 Dim InputObjectType(0)
 Set Document = CATIA.ActiveDocument
 Set Selection = Document.Selection
 
 'Selection of circular edge
 InputObjectType(0)="TriDimFeatEdge"
 Status=Selection.SelectElement2(InputObjectType,"Select the edge",true)
 if (Status = "cancel") then Exit Sub
 Set EdgeToCenter = Selection.Item(1).Value
 Selection.Clear
 
 Dim Coordinates(2)
 EdgeToCenter.GetCenter Coordinates


 MsgBox "x = " & Coordinates(0) & " ; y = " & Coordinates(1) & " ; z = " & Coordinates(2)

End Sub

itsmyjob said:
I guess you already have the output of your script: create file with proper information / format from CATIA to other tubing app.
Indeed, I have to put some information of the part into another format
itsmyjob said:
now define the input: will it be a product of part with dumb solid, solid from tubing workbench, just tubing run, user created tube geometry... define what is in scope what is not.
Here's the thing: there will be runs and dumb solids so Product all the time
itsmyjob said:
then process with logic from geometry to get the info then from info to output format. The logic to extract the info will be different from one input (tubing run) to another (user created geometry). for your standard parts I would search for edges in the solid then keep only circle one and get circle center, from that you can also get the normal direction if you need. for the tube, if you use the tubing workbench and have the run, you should be able to get the points (and bend radius) from the run. If you don't have the run but used the tubing workbench you should be able to identify the sketch that define the tube center line and then get info from vertices or edges regarding the info you need.
The problem is: I already have a macro working fine with my runs (I succeeded to extract the nodes, the coordinates of each nodes, the diameter and the bend of my runs), so my problem is on the parts because of the different components of a piping circuit. Since I will have circuit with over 100 parts in it, I have to make an autoselection

Actually, I know some programming way, but it's the first time I have something this big to do.
I may have a way to do it in a global way, but the problem is, I don't have the details to do it, like commands (and the automation file is not the best to find infos)

So thanks to everyone trying to help me!
 
You have forgotten to use measurable object. I adjusted your code a bit, it works now:

Code:
Sub CATMain()
    Dim doc, sel, spa, ref, measurable
    Dim inputObjectType(0)
    
    Set doc = CATIA.ActiveDocument
    Set sel = doc.selection
    Set spa = doc.GetWorkbench("SPAWorkbench")
 
    'Selection of circular edge
    inputObjectType(0) = "TriDimFeatEdge"
    Status = sel.SelectElement2(inputObjectType, "Select the edge", True)
    If (Status = "cancel") Then Exit Sub
        
    Set ref = sel.Item(1).Reference
    Set measurable = spa.GetMeasurable(ref)
    sel.Clear
    
    Dim Coordinates(2)
    measurable.GetCenter Coordinates
    
    MsgBox "x = " & Coordinates(0) & " ; y = " & Coordinates(1) & " ; z = " & Coordinates(2)
End Sub

Tesak
- Curved text for Catia V5
 
Humm, I tried to add
Dim Radius As Long
Set Radius = measurable.GetRadius
But it failed "GetRadius does not handle this property", but in the automation, it says that GetRadius works on circles.
And I tried Set Radius = measurable.Radius , same results.

Tried Dim oCoords(2)
measurable.GetCOG oCoords
Doesn't work too (I don't need the COG but just for test)

Did I forget something? Normally, it's on the measurable workbench and I called it before
[ponder]

I don't get why it works on GetCenter but not on GetRadius!
download.aspx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top