/// <summary> /// Gets a preview image for the given block definitions id /// </summary> /// <param name="id">Guid of the instance definition</param> /// <param name="width">width of the preview image in pixels</param> /// <param name="height">height of the preview image in pixels</param> /// <returns></returns> public static Image GetPreviewImage(Guid id, int width, int height) { var instanceAccess = new InstanceTableDataAccess(); var definition = instanceAccess.GetDefinition(id); return(GetPreviewImage(definition, width, height)); }
private static List <NestedInstanceDefinitionModel> CreateNested(InstanceDefinitionModel root) { var models = new List <NestedInstanceDefinitionModel>(); var access = new InstanceTableDataAccess(); var definition = access.GetDefinition(root.Id); int i = 0; foreach (var part in definition.GetPartInstances()) { // create model for current part var partModel = InstanceDefinitionModelFactory.Create(part.InstanceDefinition); // test if not an assembly if (!partModel.IsAssembly) { models.Add(NestedInstanceDefinitionModelFactory.Create(partModel, root, root, i)); } // if it is an assembly we have to go deeper models.AddRange( CreateNested(partModel)); i += 1; } return(models); }
/// <summary> /// Gets a preview image for the given block definitions id /// highlighting the supplied nested active part definitions id /// </summary> /// <param name="mainId">Guid of the main instance definition</param> /// <param name="activePartId">Guid of the nested part definition which should be highlighted</param> /// <param name="width">width of the preview image in pixels</param> /// <param name="height">height of the preview image in pixels</param> /// <returns></returns> public static Image GetPreviewImage(Guid mainId, Guid activePartId, int width, int height) { var instanceAccess = new InstanceTableDataAccess(); var main = instanceAccess.GetDefinition(mainId); var active = instanceAccess.GetDefinition(activePartId); return(GetPreviewImage(main, active, width, height)); }
/// <summary> /// Gets all the first level children of a Instance definition /// given its id /// </summary> /// <param name="id">The id of the Instance definition to find the children of</param> /// <returns></returns> public static IEnumerable <InstanceDefinitionModel> GetChildrenById(Guid id) { var dataAccess = new InstanceTableDataAccess(); return(dataAccess .GetNestedDefinitions(id) .Select(InstanceDefinitionModelFactory.Create)); }
/// <summary> /// Returns all Instance definition models that can be generated /// from the currently active <see cref="Rhino.RhinoDoc"/> /// </summary> /// <returns></returns> public static IEnumerable <InstanceDefinitionModel> GetInstanceDefinitions() { var dataAccess = new InstanceTableDataAccess(); return(dataAccess .GetDocumentInstanceDefinitions() .Select(InstanceDefinitionModelFactory.Create) ); }
/// <summary> /// Returns all Instance definition models that are of type assembly /// </summary> /// <returns></returns> public static IEnumerable <InstanceDefinitionModel> GetAssemblies() { var dataAccess = new InstanceTableDataAccess(); return(dataAccess .GetDocumentInstanceDefinitions() .Where(d => !d.IsRoot()) .Select(InstanceDefinitionModelFactory.Create) ); }