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.
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
CATIA has this in R24 (for example), why you need a macro?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA Automation
RE: CATIA Automation
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA Automation
RE: CATIA Automation
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
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
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
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 SubRE: CATIA Automation