I'm trying to add a stl file to an existing model as a single component, with the entities of the stl file as the component's children.
To do this, I follow the following steps:
- Create standaloneModel and componentEntity via an objectGenerator.Create("iModel_DG") and "iEntity_DG"
- Load the stl file into the standaloneModel via .Load(filename)
- Get the standaloneModel's entity array, and add it to the componentEntity via .Add(iEntityArray,-1)
- Add the componentEntity to the main model via m_iModel.AddEntity(componentEntity)
If I import the stl directly to the main model via m_iModel.Load(filename) and then delete it, it seems to be fine. If the stl file into a standalone model, and then add the entity array to the main model (instead of an intermediate componentEntity), it seems to release most but not all of the memory.
Attached are two projects I've been testing. The issue seems to appear in both. (Although, the model explorer doesn't seem to work in the C Sharp version at all.) I've tried various permutations of setting objects = nothing / null, as well as calling .RemoveAll() or .Clear on the standalone models etc.
To reproduce it - launch the application and click the Import (Component) Button. It should load the stl file in the way described above. Clicking the clear button should clear the geometry, but the memory stays allocated. Any ideas?
The attached projects require a stl file to load, which can be downloaded here: https://drive.google.com/file/d/1GZtJUN ... sp=sharing if the link doesn't work, I believe any stl file that loads into multiple meshes should be equivalent
An example of the C Sharp code that I'm trying is:
Code: Select all
private void cmdImportComp_Click(object sender, EventArgs e)
{
IModel_DG iModelStandalone;
IEntityArray_DG iArrayEnt;
IObjectGenerator_DG gen = m_iModel.Query<IObjectGenerator_DG>();
IDictionary_DG MyDictionary;
IEntity_DG MyComponentEntity;
MyDictionary = gen.Create<IDictionary_DG>();
MyDictionary.SetBool("SeperateObjects", true);
iModelStandalone = gen.Create<IModel_DG>();
MyComponentEntity = gen.Create<IEntity_DG>();
iModelStandalone.Load(txtFilePath.Text);
iArrayEnt = iModelStandalone.GetEntityArray(false);
MyComponentEntity.Add(iArrayEnt, -1);
MyComponentEntity.Name = "Component";
for (int i = 0; i < MyComponentEntity.GetChildCount(); i++)
{
MyComponentEntity.GetChildAt(i).Name = "Child_" + i.ToString();
}
m_iModel.AddEntity(MyComponentEntity);
m_iView.Reset(true, true);
m_dgkc.UpdateView();
}
Thanks!