网淘吧Visual Components、Flexsim 仿真技术博客 | Python、C#、Delphi xe 机器人编程教程 - 网淘吧

从 eCatalog 自动生成轨道段组件时位置放置错误(vcMatrix 属性修改陷阱) - Extensions and Python Add-ons - visual compents 疑难解答

2026-04-03 新闻来源:网淘吧 围观:52
电脑广告
手机广告

Dylan_7

Hello,

I have made a custom folder in eCat under ‘My Models’ with template models of the track segment components I modelled. My aim is to generate an automated track from these models using add-on files (init.pyfile andCommandfile) and instead of xml file i am using a JSON config file with segment details but no x,y,z positions. Placement is done using the segment lengths and zero position values of each segments in the config file and connection using interfaces.

Generating components from eCatalog - Extensions and Python Add-ons

The segments are being generated but their placement in the world is not correct or being correctly translated, its like they have a pose lock. Can anyone give me a hint or insights on how to tackle this problem or point out any mistakes in my approach?

Thank you

Hello,
Could you maybe provide the Code you are using to set the position of the segments. It’s hard to problemshoot the issue without this.
Also make sure to update the simulation after changing the PositionMatrix of a Component otherwise the changes won’t be visible. To do this you can use the following Code:

sim.update()
app.render()
sim.setInitialState()

Thank you for the reply

For initial segment placement:
pm = vcMatrix.new()
pm.P.X = 0.0; pm.P.Y = 0.0; pm.P.Z = 0.0
c.PositionMatrix = pm

For following segments placement:
pm = vcMatrix.new(prev_comp.WorldPositionMatrix)
nm = vcMatrix.new(next_comp.PositionMatrix)

nm.P.X = pm.P.X + delta
nm.P.Y = pm.P.Y
nm.P.Z = pm.P.Z
next_comp.PositionMatrix = nm

Currently I have only tried with app.render() as my understanding was the changes in script will get updated when I close and reopen the script. I am generating the track into an empty world.

Note that nm.P.X = 10.0 doesn’t work. That’s beacuse nm.P creates a new vcVector instance with the position value but it’s not tied to nm after its creation. So this sets the X of that copy while original matrix position remains the same. So try:
P = nm.P
P.X = 10.0
nm.P = P

This is quite common mistake and something to user needs to get used to in VC API.

-k

2 Likes

Thank you, that solved the placement issue.


免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏

文章底部电脑广告
手机广告位-内容正文底部

相关文章

上网淘巴领天猫淘宝优惠券,一年省好几千。

广告  ×

您是本站第940265名访客 今日有0篇新文章/评论