Using CATIA V5 I need to change sketch's support without moving geometry (as it can be done with CATIA UI) with automation and I can't find how to do it.
Constraint : No startcommand
and sendkeys
SetAbsoluteAxisData()
Dim coords(8)
coords(0) = 0.0#
coords(1) = 0.0#
coords(2) = 100.0#
coords(3) = 1.0#
coords(4) = 0.0#
coords(5) = 0.0#
coords(6) = 0.0#
coords(7) = 0.0#
coords(8) = 1.0#
MySketch.SetAbsoluteAxisData(coords)
Problem : The sketch's axis system change corrctly but the geometry is moved too.
Got this result :
Dim partDocument1 As PartDocument
partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
part1 = partDocument1.Part
Dim bodies1 As Bodies
bodies1 = part1.Bodies
Dim body1 As Body
body1 = bodies1.Item("Corps principal")
Dim sketches1 As Sketches
sketches1 = body1.Sketches
Dim sketch1 As Sketch
sketch1 = sketches1.Item("Esquisse.1")
Dim factory2D1 As Factory2D
factory2D1 = sketch1.OpenEdition()
Dim geometricElements1 As GeometricElements
geometricElements1 = sketch1.GeometricElements
Dim point2D1 As Point2D
point2D1 = geometricElements1.Item("Point.1")
point2D1.SetData(-19.758759, 60.20845)
Dim point2D2 As Point2D
point2D2 = geometricElements1.Item("Point.2")
point2D2.SetData(-53.244766, 60.20845)
Dim line2D1 As Line2D
line2D1 = geometricElements1.Item("Droite.1")
line2D1.SetData(-19.758759, 60.20845, -1.0#, 0.0#)
So basicly it modifies every geometrical feature manualy.
Problem : I can't predict the sketch content
Found this question : How to change sketch support in CATIA using vba?
Problem : it doesn't include the "without moving geometry" constraint.
Sorry but here is no option for that in the VB API.
The option does exist in the CAA API so I suppose if you have CAA it would be possible to develop a VB API of your own if you wanted to get behavior equivilant to what is possible in the interactive "Change Sketch Support" tool.
If all you have in your sketch simple elements, limited to points and lines for example, you should be able to repilcate the behavior by computing the transformation you are making between the sketch axis systems, and applying the inverse of that transformation to all the coordinates of your sketch geometry thus re-mapping all the geometry to the new axis. This is what you see in the recorded macro. But moving beyond simple geometry types will of course be complicated.