Using SetEntity on DModelPanel

Whenever I use SetEntity on a DModelPanel with an un-spawned entity it spawns it at the map origin anyway.

I’ll give an example:
[lua]
//This isn’t my actual code, just something similar

local Frame = vgui.Create( “DFrame” )
Frame:SetPos( 50,50 )
Frame:SetSize( 400,400 )

local Ent = ents.Create( “prop_physics” )
Ent:SetModel( “my model” )
Ent:SetMaterial( “my material” )

local MdlPnl = vgui.Create( “DModelPanel”, Frame )
MdlPnl:SetPos( 10, 10 )
MdlPnl:SetSize( 380,380 )
MdlPnl:SetCamPos( Vector( 0, -60, 30 ) )
MdlPnl:SetLookAt( Vector( 30, 180, 0) )
MdlPnl:SetEntity( Ent )
[/lua]
I don’t know why it’s spawning, because I’m not even using Ent:Spawn(). The props are annoying to look at and after too many spawn it starts to lag. I was thinking about using Ent:Remove(), but it’s still going to be visible until I do.

Is there a better alternative or is there something I can do to fix it?

You don’t need to create an entity to display it in a model panel.
I quickly changed your example to how i would do it:

[lua]
local Frame = vgui.Create( “DFrame” )
Frame:SetPos( 50,50 )
Frame:SetSize( 400,400 )

local MdlPnl = vgui.Create( “DModelPanel”, Frame )
MdlPnl:SetPos( 10, 10 )
MdlPnl:SetSize( 380,380 )
MdlPnl:SetCamPos( Vector( 0, -60, 30 ) )
MdlPnl:SetLookAt( Vector( 30, 180, 0) )
MdlPnl:SetModel( Model(“models/Gibs/HGIBS.mdl”) ) --<<
[/lua]

Ya, I would do that except I wanted one of the models to have a different material on it and I don’t think MdlPnl:SetMaterial() is valid. However I guess I can live without it.

Just wondered if there was a way to do it like this…