public async Task InvokeFunction() { var root = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../../"); var config = Hypar.Functions.Function.FromJson(File.ReadAllText(Path.Combine(root, "hypar.json"))); var store = new FileModelStore <StructureByEnvelopeInputs>(root, true); // Create an input object with default values. var input = new StructureByEnvelopeInputs(); // Read local input files to populate incoming test data. if (config.ModelDependencies != null) { var modelInputKeys = new Dictionary <string, string>(); foreach (var dep in config.ModelDependencies) { modelInputKeys.Add(dep.Name, $"{dep.Name}.json"); } input.ModelInputKeys = modelInputKeys; } // Invoke the function. // The function invocation uses a FileModelStore // which will write the resulting model to disk. // You'll find the model at "./model.gltf" var l = new InvocationWrapper <StructureByEnvelopeInputs, StructureByEnvelopeOutputs>(store, StructureByEnvelope.Execute); await l.InvokeAsync(input); }
private void OnCreateCustomUserModelDifferenceStore(object sender, CreateCustomModelDifferenceStoreEventArgs e) { if (IsHosted && _customUserModelDifferenceStore) { return; } _customUserModelDifferenceStore = true; var stringModelStores = ResourceModelCollector.GetEmbededModelStores(); foreach (var stringModelStore in stringModelStores) { e.AddExtraDiffStore(stringModelStore.Key, stringModelStore.Value); } IEnumerable <string> models = Directory.GetFiles(BinDirectory, "*.Xpand.xafml", SearchOption.TopDirectoryOnly); models = models.Concat(Directory.GetFiles(BinDirectory, "model.user*.xafml", SearchOption.TopDirectoryOnly)).Where(s => !s.ToLowerInvariant().EndsWith("model.user.xafml")); if (IsHosted) { models = models.Concat(Directory.GetFiles(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "model.user*.xafml", SearchOption.TopDirectoryOnly)); } foreach (var path in models) { string fileNameTemplate = Path.GetFileNameWithoutExtension(path); var storePath = Path.GetDirectoryName(path); var fileModelStore = new FileModelStore(storePath, fileNameTemplate); e.AddExtraDiffStore(fileNameTemplate, fileModelStore); } }
public ModelEditorViewController GetController(PathInfo pathInfo) { var storePath = Path.GetDirectoryName(pathInfo.LocalPath); var fileModelStore = new FileModelStore(storePath, Path.GetFileNameWithoutExtension(pathInfo.LocalPath)); var applicationModulesManager = GetApplicationModulesManager(pathInfo); var modelApplication = GetModelApplication(applicationModulesManager, pathInfo, fileModelStore); return GetController(fileModelStore, modelApplication); }
ModelApplicationBase GetModelApplication(ApplicationModulesManager applicationModulesManager, PathInfo pathInfo, FileModelStore fileModelStore) { var modelApplication = ModelApplicationHelper.CreateModel(XafTypesInfo.Instance, applicationModulesManager.DomainComponents, applicationModulesManager.Modules, applicationModulesManager.ControllersManager, Type.EmptyTypes, fileModelStore.GetAspects(), null, null); AddLayers(modelApplication, applicationModulesManager, pathInfo); ModelApplicationBase lastLayer = modelApplication.CreatorInstance.CreateModelApplication(); fileModelStore.Load(lastLayer); ModelApplicationHelper.AddLayer(modelApplication, lastLayer); return modelApplication; }
public ModelEditorViewController GetController(PathInfo pathInfo) { var storePath = Path.GetDirectoryName(pathInfo.LocalPath); var fileModelStore = new FileModelStore(storePath, Path.GetFileNameWithoutExtension(pathInfo.LocalPath)); var applicationModulesManager = GetApplicationModulesManager(pathInfo); var modelApplication = GetModelApplication(applicationModulesManager, pathInfo, fileModelStore); return(GetController(fileModelStore, modelApplication)); }
private void SingleChoiceActionOnExecute(object sender, SingleChoiceActionExecuteEventArgs e){ if (e.SelectedChoiceActionItem.Caption == "LoadModel"){ var modelApplicationBase = ((ModelApplicationBase)Application.Model); var creator = modelApplicationBase.CreatorInstance; var modelApplication = creator.CreateModelApplication(); modelApplication.Id = _parametrizedAction.Value.ToString(); var fileNameTemplate = _parametrizedAction.Value.ToString(); var fileModelStore = new FileModelStore(XpandModuleBase.BinDirectory, fileNameTemplate); fileModelStore.Load(modelApplication); modelApplicationBase.AddLayerBeforeLast(modelApplication); } }
public void MultiResidenceTest() { var inStore = new FileModelStore <MultiResidenceInputs>("../../../../", true); var inputs = new MultiResidenceInputs(new Hypar.Functions.Execution.InputData("../../../../parcel.csv"), 60, "", "", "", "", ""); var model = new Model(); var outputs = MultiResidence.Execute(model, inputs); System.IO.File.WriteAllText("../../../../MultiResidence.json", model.ToJson()); var outStore = new FileModelStore <Hypar.Functions.Execution.ArgsBase>("../../../../", true); model.ToGlTF("../../../../MultiResidence.glb"); }
public async Task InvokeFunction() { var store = new FileModelStore <RefrigeratedLayoutInputs>("./", true); // Create an input object with default values. var input = new RefrigeratedLayoutInputs(); // Invoke the function. // The function invocation uses a FileModelStore // which will write the resulting model to disk. // You'll find the model at "./model.gltf" var l = new InvocationWrapper <RefrigeratedLayoutInputs, RefrigeratedLayoutOutputs>(store, RefrigeratedLayout.Execute); var output = await l.InvokeAsync(input); }
private void SingleChoiceActionOnExecute(object sender, SingleChoiceActionExecuteEventArgs e) { if (e.SelectedChoiceActionItem.Caption == "LoadModel") { var modelApplicationBase = ((ModelApplicationBase)Application.Model); var creator = modelApplicationBase.CreatorInstance; var modelApplication = creator.CreateModelApplication(); modelApplication.Id = _parametrizedAction.Value.ToString(); var fileNameTemplate = _parametrizedAction.Value.ToString(); var fileModelStore = new FileModelStore(XpandModuleBase.BinDirectory, fileNameTemplate); fileModelStore.Load(modelApplication); modelApplicationBase.AddLayerBeforeLast(modelApplication); } }
public async Task InvokeFunction() { var store = new FileModelStore <FacadeByEnvelopeInputs>("./", true); // Create an input object with default values. var input = new FacadeByEnvelopeInputs(); // Invoke the function. // The function invocation uses a FileModelStore // which will write the resulting model to disk. // You'll find the model at "./model.gltf" var l = new InvocationWrapper <FacadeByEnvelopeInputs, FacadeByEnvelopeOutputs>(store, FacadeByEnvelope.Execute); var output = await l.InvokeAsync(input); var json = output.model.ToJson(); File.WriteAllText("../../../facade.json", json); }
ModelApplicationBase GetModelApplication(ApplicationModulesManager applicationModulesManager, PathInfo pathInfo, FileModelStore fileModelStore) { var modelApplication = ModelApplicationHelper.CreateModel(XafTypesInfo.Instance, applicationModulesManager.DomainComponents, applicationModulesManager.Modules, applicationModulesManager.ControllersManager, Type.EmptyTypes, fileModelStore.GetAspects(), null, null); AddLayers(modelApplication, applicationModulesManager, pathInfo); Tracing.Tracer.LogText("AddLayers"); ModelApplicationBase lastLayer = modelApplication.CreatorInstance.CreateModelApplication(); fileModelStore.Load(lastLayer); ModelApplicationHelper.AddLayer(modelApplication, lastLayer); return(modelApplication); }
ModelEditorViewController GetController(FileModelStore fileModelStore, ModelApplicationBase modelApplication) { return(new ModelEditorViewController((IModelApplication)modelApplication, fileModelStore)); }
ModelApplicationBase GetModelApplication(ApplicationModulesManager applicationModulesManager, PathInfo pathInfo, FileModelStore fileModelStore) { var modelsManager = new ApplicationModelsManager(applicationModulesManager.Modules, applicationModulesManager.ControllersManager, applicationModulesManager.DomainComponents, null, fileModelStore.GetAspects()); var modelApplication = (ModelApplicationBase)modelsManager.CreateModel(modelsManager.CreateApplicationCreator(), null, false); AddLayers(modelApplication, applicationModulesManager, pathInfo); return modelApplication; }
ModelEditorViewController GetController(FileModelStore fileModelStore, ModelApplicationBase modelApplication) { fileModelStore.Load(modelApplication.LastLayer); return new ModelEditorViewController((IModelApplication)modelApplication, fileModelStore); }
ModelEditorViewController GetController(FileModelStore fileModelStore, ModelApplicationBase modelApplication) { return new ModelEditorViewController((IModelApplication)modelApplication, fileModelStore); }
ModelEditorViewController GetController(FileModelStore fileModelStore, ModelApplicationBase modelApplication) => new((IModelApplication)modelApplication, fileModelStore);