cancel
Showing results for 
Search instead for 
Did you mean: 

I would like to model some solids by the API

Siemens Pioneer Siemens Pioneer
Siemens Pioneer

Question:

 

I would like to model some solids (sphere, cylinder, etc) by the api.

to do that a ressource must be loaded from the library and it must be set to modelling.

 

once i’ve loaded the ressource and set it to modeling by hand, my api can create solids by

TxCylinderCreationData data = new TxCylinderCreationData(name, basVec, topVec, radius);

TxSolid solid = cylinder.CreateSolidCylinder(data);

so thats fine for the moment but i don’t want the user to load a ressource manualy from the library and run my api afterwards.

 

of course it is possible to load a cojt by:

TxInsertComponentCreationData txInsertComponentCreationData = new TxInsertComponentCreationData(this.Name, this.m_FullPath());

IxLocatableObject txLocatableObject = (ITxLocatableObject)TxApplication.ActiveDocument.PhysicalRoot.InsertComponent(txInsertComponentCreationData);

but then, the user has to create a dummy *.cojt and put in the library.

 

to get a ressource to modeling i’ve tried, but i didn’t found the correct string for the command

TxApplication.CommandsManager.ExecuteCommand("Modeling.SetModelingScope");

  

is there an easy way to create ressources by the api, and set it to modeling,

so that api developers can use the pretty handy functions of creating solids?

 

Answer: 

 

Currently the .NET API does not expose a method to create a component/resource directly under the study.

You can use the CreateLocalComponent method to create a jt file. Then you can use the Convert and Insert CAD files command to insert it to a library or Create Engineering Library.

 

TxLocalComponentCreationData crData = new TxLocalComponentCreationData("test");

TxComponent comp = TxApplication.ActiveDocument.PhysicalRoot.CreateLocalComponent(crData);

TxLocalStorage storage = comp.StorageObject as TxLocalStorage;

string path = storage.SaveComponent();

 

Regarding the Set Modeling Scope, we have a new method in V12.1.1 on ITxComponent interface – SetModelingScope and EndModeling