×
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

CATIA Automation

CATIA Automation

CATIA Automation

(OP)
Hi everyone,

I need to automate the creation of point coordinates annotation in the FTA workbench in CATIA. As far as I have been able to find out, DS has not exposed the method for creating coordinate dimension. Is there anyway we can do it?

Attached is the screenshot for what I need
Thanks for all your help. Please let me know if you need more information.

RE: CATIA Automation

(OP)
Thanks for your reply. I know the option you are pointing out is available in CATIA. The reason I want to automate it is because I am copying a number of elements from one file to another. when these elements are copied, they need to be annotated with the coordinates of the points. this is a new process we are implementing and the designer will not have enough time to annotate the points manually. so we are creating a utility that let's the designer do it at the click of a button.

RE: CATIA Automation

(OP)
yes Ferdo we tried that. We measured the coordinates of the point and entered them as a text string. However, here the problem is that the new annotation is no longer associative. that is, it does not change with the change in the location of the points and we have to re-run the code once again to re-create the annotation for it. How can we achieve the solution here?

RE: CATIA Automation

So you copy the points in and can later change the coordinates of the points that were copied in?

If you want the annotation to update you need to make length parameters that are tied to the coordinates of the points, then attribute link those parameters to your annotation.

You can create three length parameters (X,Y,Z) using the .CreateDimension method
You need to create a formula to tie the point coordinates to the three parameters using the .Relations.CreateFormula method and KWE "Point->coord(rank)" (where rank = 1 for x, 2 for y and 3 for z) for the formula.

Once you have the parameters associated to the point coordinates you can attribute link the text using the .InsertVariable method.

RE: CATIA Automation

(OP)
Thanks lardman363 for the idea. Though I am not sure how well it will work for us.

Let me try and describe in more detail the scenario here:
1. A part, let's say A, is created by the designer.
2. A derivative part from the part A is created by publishing the part body and copying it with the "As Result With Link" option in paste special command into another part, say B.
3. Another person uses part B to design some points and patches as per his requirement inside a single geometrical set. At the end of his work, he publishes all the elements he has created.
4. These published parts are then copied back to the part A in the same way, i.e., "As Result With Link"
5. Now in part A, we need to annotate the points with the coordinate dimensions of the copied points. This is where we are stuck at now. Creating the annotations the first time is easy. It is updating them is the difficulty. Maybe I should mention here that the points are created on surface based on the requirement and not as coordinate points.

I will give the idea a try and see what happens. In the meanwhile any more help would be greatly appreciated.

Cheers!!!

RE: CATIA Automation

If you reference part A into part B, you cannot reference points from part B back into part A...that creates a circular reference...so I am a bit confused on that.

But regardless of that issue...
If you want the annotation to update, you need to have parameters for the XYZ coordinates and attribute link them to the annotation.

To do this in a macro you need to do what I suggested above.

RE: CATIA Automation

Here's what I got, worked well.

CODE --> VBA

'Paste into Visual Basic
'Open a part
'Second geoset in the Part must contain the points (you can change this)
'Run the macro
'Macro will:
'  -Loop through all points
'  -Create XYZ parameters under the point
'  -Create a formula for XYZ parameters so they equal the location
'  -Create an annotation set and view parallel to the ZX plane (you can change this)
'  -Create annotations for the coordinates
'If you move a point on surface, the annotation updates to the new point coordinates
'*If you run it twice it will put more parameters under the points
'*Had to comment out setting oPartProduct because an open part doesn't have an associated product...but it ran fine
Sub CATMain()
	'Part declarations
	Dim oPart As Part
	Dim oPartDocument As PartDocument
	Dim oPartProduct As Product
	Dim oSelection As Selection
	Dim oRelations As Relations
	Dim oParameters As Parameters
	Dim oOriginElements As OriginElements
	Dim oXYPlane
	Dim oYZPlane
	Dim oZXPlane
	Dim oGeoset As HybridBody
	
	'Point declarations
	Dim oPoint As Point
	Dim oPointParameters As Parameters
	Dim xParam As Length
	Dim yParam As Length
	Dim zParam As Length
	Dim xFormula As Formula
	Dim yFormula As Formula
	Dim zFormula As Formula
	
	'Annotation declarations
	Dim oText As DrawingText
	Dim oUserSurfaces As UserSurfaces

	'Set part variables
	Set oPart = CATIA.ActiveDocument.Part
	Set oPartDocument = oPart.Parent
	'Set oPartProduct = oPartDocument.Product
	Set oSelection = oPartDocument.Selection
	Set oRelations = oPart.Relations
	Set oParameters = oPart.Parameters
	Set oOriginElements = oPart.OriginElements
	Set oXYPlane = oOriginElements.PlaneXY
	Set oYZPlane = oOriginElements.PlaneYZ
	Set oZXPlane = oOriginElements.PlaneZX
	Set oGeoset = oPart.HybridBodies.Item(2)'Change number to match the location of your geoset
	Set oUserSurfaces = oPart.UserSurfaces

	'make an annotation set If there isn't one
	Set oAnnotationSets = oPart.AnnotationSets
	
	If oAnnotationSets.Count = 1 Then
		Set oAnnotationSet = oAnnotationSets.Item(1)
	Else
		Set oAnnotationSet = oAnnotationSets.AddInAProduct(oPartProduct, "1")
		oPart.UpdateObject oAnnotationSet
	End If
	
	Set oAnnotationFactory = oAnnotationSet.AnnotationFactory

	'Create annotation View
	oSelection.Clear
	oSelection.Add oZXPlane 'Change the plane that is selected to put annotations on a different plane
	CATIA.StartCommand "Front View"
	Set oView = oAnnotationSet.TPSViews.Item(oAnnotationSet.TPSViews.Count)
	oSelection.Clear
	oView.Name = "View for point coordinates"
	'Hide the annotation view frame
	oPart.UpdateObject oAnnotationSet
	oSelection.Clear
	oSelection.Add oView
	oSelection.VisProperties.SetShow catVisPropertyNoShowAttr
	oSelection.Clear

	'Loop through the points in the geoset
	For I = 1 To oGeoset.HybridShapes.Count
		'Get a point in the geoset
		Set oPoint = oGeoset.HybridShapes.Item(I)
		
		'Make XYZ parameters for point, under the point
		oSelection.Clear
		oSelection.Add oPoint
		Set oPointParameters = oParameters.SubList(oPoint, True)
		Set xParam = oPointParameters.CreateDimension("xCoord", "LENGTH", 0)
		Set yParam = oPointParameters.CreateDimension("yCoord", "LENGTH", 0)
		Set zParam = oPointParameters.CreateDimension("zCoord", "LENGTH", 0)
		oSelection.Clear
		
		'Make formulas so the parameters update when the point is moved
		Set xFormula = oRelations.CreateFormula("xCoordRel", "", xParam, oPart.Parameters.GetNameToUseInRelation(oPoint) & "->coord(1)")
		Set yFormula = oRelations.CreateFormula("yCoordRel", "", yParam, oPart.Parameters.GetNameToUseInRelation(oPoint) & "->coord(2)")
		Set zFormula = oRelations.CreateFormula("zCoordRel", "", zParam, oPart.Parameters.GetNameToUseInRelation(oPoint) & "->coord(3)")
		
		'Create dummy annotation
		Set oRefPoint = oPart.CreateReferenceFromObject(oPoint)
		Set oUserSurface = oUserSurfaces.Generate(oRefPoint)
		Set oAnnotation = oAnnotationFactory.CreateEvoluateText(oUserSurface, 10, 10, 10, True)
		oAnnotation.Text.Text = "X=a" & vbCrLf & "Y=b" & vbCrLf & "Z=c"
		
		'Attribute link dummy annotation
		Set oText = oAnnotation.Text.Get2dAnnot
		oText.InsertVariable 11, 1, xParam
		oText.InsertVariable 7, 1, yParam
		oText.InsertVariable 3, 1, zParam
		oText.ActivateFrame catRectangle
		
	Next
	
	oPart.UpdateObject oAnnotationSet
	
End Sub 

RE: CATIA Automation

(OP)
Thanks a lot!! I will run this and try....

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