改变草图支持而不移动几何(Change sketch support without moving geometry)

编程入门 行业动态 更新时间:2024-10-25 22:35:54
改变草图支持而不移动几何(Change sketch support without moving geometry)

我的问题

使用CATIA V5我需要改变草图的支持而不用移动几何图形(因为它可以通过CATIA用户界面来完成),而且我无法找到如何去做。

约束:没有startcommand和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)

录制宏

得到这个结果:

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#)

搜索Stackoverflow

发现这个问题: 如何使用vba在CATIA中更改草图支持?

问题:它不包括“没有移动几何”约束。

My Problem

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

My attempts

Using sketch's method 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)

Recording macro

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#)

Searching Stackoverflow

Found this question : How to change sketch support in CATIA using vba?

Problem : it doesn't include the "without moving geometry" constraint.

最满意答案

对不起,但在VB API中没有这个选项。

这个选项在CAA API中确实存在,所以我猜想如果你有CAA,如果你想在交互式的“Change Sketch Support”工具中获得同样的行为,可以开发自己的VB API。

如果您在草图中绘制了简单元素(仅限于点和线),那么您应该能够通过计算草图轴系统之间的变换并将该变换的逆应用于所有坐标来重新定位行为从而将所有几何图形重新映射到新轴。 这是您在录制的宏中看到的内容。 但是,超越简单的几何类型当然会变得复杂。

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.

更多推荐

本文发布于:2023-08-07 08:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:草图   而不   几何   Change   geometry

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!