Loading multiple stl

Technical discussions
Post Reply
atrev
Posts: 24
Joined: Tue Jul 30, 2013 9:19 am

Loading multiple stl

Post by atrev »

What is the best way to load in multiple STL files into the same control?

The only way I can seem to do this is to load the STL into a separate control, and then copy the sections loaded in the object array of the main control?
I don't really want the seperate control on the form if I can help it.

Is there a neater way to do this?

Thanks

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Loading multiple stl

Post by nickz »

Hello
You do not need another control.

It is done by creating new model in memory, getting its IModelEx and using IModelEx.Load() like in Samples\NET\C#\3DBugger\DebuggerForm.cs :
IModel iModel = (IModel)m_iDIObjGenerator.Create(EObjectType.eObjTypeModelGenerator);
IModelEx iModelEx = (IModelEx)iModel;
iModelEx.Load(strPath);
.. copy objects into the main model
The format is detected by the extension of strPath. It can be stl, glm, etc

The DataFlow example demonstrates this. It has File>Add Objects menu option. C# version in Samples\NET\C#\DataFlow\DataFlowForm.cs OnImportObjects() uses a tiny library to show using sharing code with KC. It is not relevant here. You can just copy code from Samples\NET\C#\KernCADLib\ModelManager.cs ImportObjects()

If you need numerous stl load operations it is better to convert them all in a loop as background operation to .glm. Stl load with all the analysis checks is slow for large files
Nick

atrev
Posts: 24
Joined: Tue Jul 30, 2013 9:19 am

Re: Loading multiple stl

Post by atrev »

using this code for load, accessing the stl context to turn off the dialog when opening but it doesn't seem to stop it happening

Code: Select all

 Dim allObjects As IArray = CType(AxKernCADnet1.GetModel, IArray)
For i As Integer = 0 To ofd.FileNames.Length - 1
    If File.Exists(ofd.FileNames(i)) Then
        Dim m_iDIObjGenerator As IDIObjGenerator = CType(AxKernCADnet1.GetView, IDIObjGenerator)


        Dim mdl As IModelEx = CType(m_iDIObjGenerator.Create(EObjectType.eObjTypeModelGenerator), IModelEx)


        Dim options As KernCADnet.ISTLDataContext = CType(mdl, ISTLDataContext)
        options.SetVerbose(False)
        options.SetNoWarnings(True)
        options.SetSeparateObjects(False)


        mdl.LoadEx(ofd.FileNames(i), options)
        Dim mdl2 As IModel = CType(mdl, IModel)

        For j As Integer = 0 To mdl2.GetSectionCount - 1
            allObjects.Add(mdl2.GetSection(j))
        Next


    End If
Next

nickz
Site Admin
Posts: 236
Joined: Fri Jul 26, 2013 3:58 am

Re: Loading multiple stl

Post by nickz »

We have fixed this one in update 3752: http://www.dynoinsight.com/ProDown.htm
BTW this is a different issue. It should be another thread on bugs forum
Thanks
Nick

Post Reply