Layout with python script

I just used this software soon. Now I have a problem, I want to import components into the 3d world through python script and can layout according to the coordinates I entered. Can anyone give me some advice?

Cheers!

Currently, you can do this.

from vcScript import *

app = getApplication()
component = app.findComponent("Block")
if component:
  component.delete()
uri = "file:///"+r"C:\Users\Public\Documents\Visual Components\4.1\Models\eCatalog 4.1\Components\Visual Components\BasicShapes\BlockGeo.vcmx"
component = app.load(uri)
pm = component.PositionMatrix
pm.translateAbs(500,500,0)
component.PositionMatrix = pm
app.render()

There are the loadLayout and loadLayoutToPosition commands. There is a known issue with loadLayoutToPosition, which has been fixed and should be available in next release.

Thank you very much!

I tried it and it really works. However, the model can only be imported on the basis of existing components, and cannot be imported directly. I also tried adding the python script to Mycommand to run, but it doesn’t seem to work. Can the loadLayoutToPosition function be implemented in version 4.1?

cheers!

I don’t know what this means. There is a separate command for importing geometry.

"However, the model can only be imported on the basis of existing components, and cannot be imported directly. "

No, loadLayoutToPosition is defined in source code, so you have to wait for release or implement your own version. For example, create add-on that has function for calling load() and another argument for the position you want for that item. Otherwise, you could do everything you want to do in .NET and there is already a post on the forum on how to do that in .NET side.

 

Thanks a lot for your support!

:stuck_out_tongue: :wink: