internal ImageBuffer(SU.TextureRef suTextureRef) { SU.ImageRepRef suImageRepRef = new SU.ImageRepRef(); SU.ImageRepCreate(suImageRepRef); // This gets either the non-colorized image, if the texture // is not colorized, or else a colorized version. // TODO: Find out how the HLS deltas work. Note that the // ability to colorize is SketchUp-specific. SU.TextureGetColorizedImageRep(suTextureRef, suImageRepRef); SU.ImageRepGetPixelDimensions(suImageRepRef, out width, out height); SU.ImageRepGetRowPadding(suImageRepRef, out rowPadding); SU.ImageRepGetDataSize(suImageRepRef, out dataSize, out bitsPerPixel); bytesPerPixel = bitsPerPixel / bitsPerByte; // Check for a match. if (dataSize != height * (width * bytesPerPixel + rowPadding)) { throw new System.Exception("Data size of ImageRep conflicts with dimensions."); } pixelData = new byte[dataSize]; SU.ImageRepGetData(suImageRepRef, dataSize, pixelData); }
public void Recorrer() { foreach (Sucursales SU in ss) { Console.WriteLine(SU.DarDireccion()); } }
internal CompDef( SU.ComponentDefinitionRef componentDefinitionRef) { // Get the name. SU.StringRef stringRef = new SU.StringRef(); SU.StringCreate(stringRef); SU.ComponentDefinitionGetName(componentDefinitionRef, stringRef); Name = Convert.ToStringAndRelease(stringRef); // Get the description. stringRef = new SU.StringRef(); SU.StringCreate(stringRef); SU.ComponentDefinitionGetDescription(componentDefinitionRef, stringRef); Description = Convert.ToStringAndRelease(stringRef); // Get the entities. SU.EntitiesRef entitiesRef = new SU.EntitiesRef(); SU.ComponentDefinitionGetEntities(componentDefinitionRef, entitiesRef); //entities = new Entities(entitiesRef); UnpackEntities(entitiesRef); }
private SyntaxList <MemberDeclarationSyntax> CreateCreateFunctions() { var returnType = SU.ClassNameWithGenerics(m_class); var retType = SF.IdentifierName(returnType); var withFn = SF.MethodDeclaration(retType, "create") .WithModifiers(SyntaxTokenList.Create(SF.Token(SyntaxKind.PublicKeyword)).Add(SF.Token(SyntaxKind.StaticKeyword))); var paramList = CreateAssignCheckBlock(); withFn = withFn.WithParameterList(SF.ParameterList(paramList)); var block = SF.Block(); block = block.WithStatements(CreateAssignments("def.", "0")); withFn = withFn.WithBody(block); var list = new SyntaxList <MemberDeclarationSyntax>(); list = list.Add(withFn); return(list); }
private SyntaxList <MemberDeclarationSyntax> CreateVersion() { var list = new SyntaxList <MemberDeclarationSyntax>(); /* * var versionField = $"private unsigned long m_version = 0"; * * var versionAcc = $"public unsigned long Version => m_version"; * * var versionFieldParsed = SF.ParseStatement( versionField ); * * var versionAccParsed = SF.ParseStatement( versionAcc ); */ var versionField = SU.Field("m_version", "ulong", SF.ParseExpression("0"), SyntaxKind.ProtectedKeyword); var versionAcc = SF.PropertyDeclaration(SF.IdentifierName("ulong"), "Version"); versionAcc = versionAcc.WithExpressionBody(SF.ArrowExpressionClause(SF.ParseExpression("m_version"))) .WithSemicolonToken(SF.Token(SyntaxKind.SemicolonToken)) .WithModifiers(new SyntaxTokenList(SF.Token(SyntaxKind.PublicKeyword))); list = list.Add(versionField); list = list.Add(versionAcc); return(list); }
async Task UpdateInfo() { if (Common.Flags.AutoUpdateEnabled && !SU.ExistsAndIsValid(Common.Paths.EntryLocation)) { await TryCheckForUpdates().ConfigureAwait(false); } }
bool TryRunUpdaterIfValid(params string[] startupParams) { try { if (!SU.ExistsAndIsValid(Common.Paths.EntryLocation)) { return(false); } if (Common.Flags.LockDown) { SU.PerformSelfUpdate(SelfUpdaterCommands.UpdateCommand, GetLockDownParameter()); } else { SU.PerformSelfUpdate(SelfUpdaterCommands.UpdateCommand, startupParams); } _shutdownHandler.Shutdown(); return(true); } catch (Exception e) { UserErrorHandler.HandleUserError(new InformationalUserError(e, "An error occurred while trying to initiate self-update. See log file for details.\nPlease try again later...", null)); return(false); } }
public override void Run(string path) { SU.EntitiesRef entities = SUHelper.Initialize(); SU.GeometryInputRef geometry = new SU.GeometryInputRef(); SU.GeometryInputCreate(geometry); foreach (SU.Point3D p in points) { SU.Point3D pc = p; pc.x *= SU.MetersToInches; pc.y *= SU.MetersToInches; pc.z *= SU.MetersToInches; SU.GeometryInputAddVertex(geometry, pc); } SU.LoopInputRef loop = new SU.LoopInputRef(); SU.LoopInputCreate(loop); SU.LoopInputAddVertexIndex(loop, 0); SU.LoopInputAddVertexIndex(loop, 1); SU.LoopInputAddVertexIndex(loop, 2); SU.LoopInputAddVertexIndex(loop, 3); long faceIndex; SU.GeometryInputAddFace(geometry, loop, out faceIndex); SU.EntitiesFill(entities, geometry, true); SUHelper.Finalize(path + @"\PlainQuad.skp"); }
internal Material(SU.MaterialRef suMaterialRef) { // Get the name. SU.StringRef suStringRef = new SU.StringRef(); SU.StringCreate(suStringRef); SU.MaterialGetNameLegacyBehavior(suMaterialRef, suStringRef); Name = Convert.ToStringAndRelease(suStringRef); // Get the types. SU.MaterialGetType(suMaterialRef, out suMaterialType); SU.MaterialGetColorizeType(suMaterialRef, out suMaterialColorizeType); // Get the color and/or texture. SU.Color suColor; SU.TextureRef suTextureRef; switch (suMaterialType) { case SU.MaterialType_Colored: SU.MaterialGetColor(suMaterialRef, out suColor); Color = new Color(suColor); break; case SU.MaterialType_Textured: suTextureRef = new SU.TextureRef(); SU.MaterialGetTexture(suMaterialRef, suTextureRef); Texture = new Texture(suTextureRef); break; case SU.MaterialType_ColorizedTexture: SU.MaterialGetColor(suMaterialRef, out suColor); Color = new Color(suColor); suTextureRef = new SU.TextureRef(); SU.MaterialGetTexture(suMaterialRef, suTextureRef); Texture = new Texture(suTextureRef); break; default: throw new Exception($"Unknown material type = {suMaterialType}"); } }
public static string ToStringAndRelease(SU.StringRef suStringRef) { string convertedString = ToString(suStringRef); SU.StringRelease(suStringRef); return(convertedString); }
public async Task TryCheckForUpdates() { if (SU.NewVersionDownloaded || SU.IsRunning || !Common.Flags.SelfUpdateSupported) { return; } await SU.CheckForUpdate().ConfigureAwait(false); }
public Point2 Coords(Point3 v) { SU.Point3D point = new SU.Point3D(v.X, v.Y, v.Z); SU.UVQ uvq = new SU.UVQ(); SU.UVHelperGetFrontUVQ(uvHelperRef, point, out uvq); return(new Point2(uvq.u / uvq.q, uvq.v / uvq.q)); }
// Handles forward-references. internal void GuaranteeReference() { if (componentDefinitionRef == null) { componentDefinitionRef = new SU.ComponentDefinitionRef(); SU.ComponentDefinitionCreate(componentDefinitionRef); } }
bool UpdateAndExitIfNeeded() { if (!SU.ExistsAndIsValid(Common.Paths.EntryLocation)) { return(false); } TryRunUpdaterIfValid(Common.Flags.FullStartupParameters); return(true); }
/// <summary> /// Load a texture from an image file, specifying its scale. /// </summary> /// <param name="filename"></param> /// <param name="xScale"></param> /// <param name="yScale"></param> public Texture(string filename, double xScale, double yScale) { SU.TextureRef textureRef = new SU.TextureRef(); SU.TextureCreateFromFile(textureRef, filename, xScale, yScale); imageBuffer = new ImageBuffer(textureRef); SU.TextureRelease(textureRef); }
public static SU.EntitiesRef Initialize() { SU.Initialize(); model = new SU.ModelRef(); SU.ModelCreate(model); SU.EntitiesRef entities = new SU.EntitiesRef(); SU.ModelGetEntities(model, entities); return(entities); }
internal Face(SU.FaceRef suFaceRef) { // Get its UVHelper for texture-mapping coordinates. UVHelper uvh = new UVHelper(suFaceRef); // Get the outer loop. EdgePointList edgePointList = new EdgePointList(suFaceRef); uvh.Assign(edgePointList); outerLoop = new Loop(edgePointList).edgePoints; // Get any inner loops. SU.FaceGetNumInnerLoops(suFaceRef, out long count); SU.LoopRef[] loopRefs = new SU.LoopRef[count]; long len = count; SU.FaceGetInnerLoops(suFaceRef, len, loopRefs, out count); foreach (SU.LoopRef loopRef in loopRefs) { innerLoops.Add( new Loop(new EdgePointList(loopRef)).edgePoints); } SU.MaterialRef suMaterialRef = new SU.MaterialRef(); try { SU.FaceGetFrontMaterial(suFaceRef, suMaterialRef); SU.StringRef suStringRef = new SU.StringRef(); SU.StringCreate(suStringRef); SU.MaterialGetNameLegacyBehavior(suMaterialRef, suStringRef); MaterialName = Convert.ToStringAndRelease(suStringRef); } catch (SketchUpException e) { if (e.ErrorCode == SU.ErrorNoData) { // Not an error. It just has no material. } else { throw; } } }
internal void Pack(Model model, SU.EntitiesRef entitiesRef) { CompDef componentDefinition = model.components[ComponentName]; // We might be making a forward reference, so guarantee // that the ComponentDefinition has a SketchUp pointer. componentDefinition.GuaranteeReference(); SU.ComponentDefinitionRef componentDefinitionRef = componentDefinition.componentDefinitionRef; SU.ComponentInstanceRef componentInstanceRef = new SU.ComponentInstanceRef(); SU.ComponentDefinitionCreateInstance( componentDefinitionRef, componentInstanceRef); SU.EntitiesAddInstance( entitiesRef, componentInstanceRef, null); SU.ComponentInstanceSetName( componentInstanceRef, InstanceName); SU.ComponentInstanceSetTransform( componentInstanceRef, Transform.SUTransformation); if (MaterialName != null) { Material material = null; try { material = model.materials[MaterialName]; } catch (Exception e) { string msg = "\nCould not find a material named " + MaterialName; throw new Exception(e.Message + msg); } SU.DrawingElementRef drawingElementRef = SU.ComponentInstanceToDrawingElement(componentInstanceRef); SU.DrawingElementSetMaterial( drawingElementRef, material.suMaterialRef); } }
internal EdgePoint(SU.EdgeRef edgeRef, SU.VertexRef vertexRef) { SU.EdgeGetSmooth(edgeRef, out bool isSmooth); IsSmooth = IsSmooth; SU.Point3D point = new SU.Point3D(); SU.VertexGetPosition(vertexRef, ref point); Vertex = new Point3(point); }
public Class() { SU u = SU.NewCase(item: 123); int t = u.Tag; int i = u.Item; bool isCaseError = u.IsCase; int tagsError = U.Tags.CaseA; U.Case c = (U.Case)u; }
public static string ClassNameWithGenerics(ClassDeclarationSyntax cls) { if (cls?.TypeParameterList?.Parameters == null) { return(cls.Identifier.ValueText); } var typeList = cls.TypeParameterList.Parameters.Select(p => SU.GetFullName(p)); var types = string.Join(", ", typeList.Select(t => t.WithoutTrivia().ToString())); return($"{cls.Identifier.ValueText}<{types}>"); }
public UVHelper(SU.FaceRef faceRef) { SU.TextureWriterRef textureWriterRef = new SU.TextureWriterRef(); uvHelperRef = new SU.UVHelperRef(); SU.FaceGetUVHelper( faceRef, true, false, textureWriterRef, uvHelperRef); }
internal V_SU(SeamlessViewsContext Context, SU SU) : base(Context) { var KCY = SU.SUBJECT_ACADEMIC_YEAR_KCY; _SUKEY = SU.SUKEY; _SHORTNAME = SU.SHORTNAME; _FULLNAME = SU.FULLNAME; _OVERVIEW = SU.OVERVIEW; _FACULTY = SU.FACULTY; _SEMESTER = SU.SEMESTER; _SUBJECT_ACADEMIC_YEAR = SU.SUBJECT_ACADEMIC_YEAR; _DESCRIPTION = KCY.DESCRIPTION; }
public HttpDownLoadFileInfo GetHttpDownLoadFileInfo() { if (request == null) { throw new Exception("not initialized"); } String fileName = SU.InTheMiddle(response.Headers["Content-Disposition"], "filename=", ""); return(new HttpDownLoadFileInfo() { FileName = fileName, FileSize = response.ContentLength }); }
protected void UnpackEntities(SU.EntitiesRef entitiesRef) { // Get the faces. long count; SU.EntitiesGetNumFaces(entitiesRef, out count); SU.FaceRef[] faceRefs = new SU.FaceRef[count]; long len = count; SU.EntitiesGetFaces(entitiesRef, len, faceRefs, out count); foreach (SU.FaceRef faceRef in faceRefs) { Faces.Add(new Face(faceRef)); } // Get the groups. SU.EntitiesGetNumGroups(entitiesRef, out count); SU.GroupRef[] groupRefs = new SU.GroupRef[count]; len = count; SU.EntitiesGetGroups(entitiesRef, len, groupRefs, out count); foreach (SU.GroupRef groupRef in groupRefs) { Groups.Add(new Group(groupRef)); } // Get the instances. SU.EntitiesGetNumInstances(entitiesRef, out count); SU.ComponentInstanceRef[] instanceRefs = new SU.ComponentInstanceRef[count]; len = count; SU.EntitiesGetInstances(entitiesRef, len, instanceRefs, out count); foreach (SU.ComponentInstanceRef instanceRef in instanceRefs) { Instances.Add(new CompInst(instanceRef)); } }
public Class1() { U? uError = U.NewCase(item: 123); SU?su = SU.NewCase(item: 123); SU u = su.Value; int t = u.Tag; int i = u.Item; bool isCaseError = u.IsCase; int tagsError = U.Tags.CaseA; U.Case c = (U.Case)u; }
void AddBlade( int n, SU.ComponentDefinitionRef parent, SU.ComponentDefinitionRef child, double twist, double spin) { // Instance the child. SU.ComponentInstanceRef ci = new SU.ComponentInstanceRef(); SU.ComponentDefinitionCreateInstance(child, ci); // Set its transform. SU.Transformation twistTrans = new SU.Transformation(); SU.TransformationRotation( ref twistTrans, new SU.Point3D { x = 0, y = 0, z = 0 }, new SU.Vector3D { x = 0, y = 0, z = 1 }, twist); SU.Transformation spinTrans = new SU.Transformation(); SU.TransformationRotation( ref spinTrans, new SU.Point3D { x = 0, y = 0, z = 0 }, new SU.Vector3D { x = 0, y = 1, z = 0 }, spin); SU.Transformation trans = new SU.Transformation(); SU.TransformationMultiply(ref spinTrans, ref twistTrans, ref trans); SU.ComponentInstanceSetTransform(ci, trans); SU.ComponentInstanceSetName(ci, $"Blade #{n}"); SU.EntitiesRef parentEnts = new SU.EntitiesRef(); SU.ComponentDefinitionGetEntities(parent, parentEnts); SU.EntitiesAddInstance(parentEnts, ci, null); }
private SeparatedSyntaxList <ParameterSyntax> CreateAssignCheckBlock() { var paramList = new SeparatedSyntaxList <ParameterSyntax>(); foreach (var f in m_fields) { var param = SF.Parameter(ModifyToken("{0}Opt", f.Key.Identifier)) .WithType(f.Value); param = SU.Optional(param); paramList = paramList.Add(param); } return(paramList); }
void UnpackMaterials(SU.ModelRef modelRef) { SU.ModelGetNumMaterials(modelRef, out long count); SU.MaterialRef[] materialRefs = new SU.MaterialRef[count]; long len = count; SU.ModelGetMaterials(modelRef, len, materialRefs, out count); foreach (SU.MaterialRef materialRef in materialRefs) { Material material = new Material(materialRef); materials.Add(material.Name, material); } }
internal void Pack(Model model, SU.ModelRef modelRef) { // The SketchUp API appears to add a "persistent ID" to vertices, // edges, and faces, as they are added to definitions and groups. // But it also appears not to do this unless the definition or // group reference has already been added to the model. If you // add those references to the model after creating their contents, // SketchUp will detect the missing IDs on load and "fix" them, // causing SketchUp to ask if you want to save the changes when // you close (even though you won't think you've made any). // // You can see this in the "Edit / Undo Check Validity" menu item // when it happens. Undo it, and then use the "Window / Model info" // dialog, under "Statistics" by pressing the "Fix Problems" // button. You'll get a report on the missing persistent IDs. // // To prevent all this from happening, we add the reference first. GuaranteeReference(); SU.ComponentDefinitionRef[] componentDefinitionsArray = new SU.ComponentDefinitionRef[1]; componentDefinitionsArray[0] = componentDefinitionRef; SU.ModelAddComponentDefinitions( modelRef, 1, componentDefinitionsArray); SU.ComponentDefinitionSetName( componentDefinitionRef, Name); SU.ComponentDefinitionSetDescription( componentDefinitionRef, Description); SU.EntitiesRef myEntitiesRef = new SU.EntitiesRef(); SU.ComponentDefinitionGetEntities(componentDefinitionRef, myEntitiesRef); //entities.Pack(model, myEntitiesRef); Pack(model, myEntitiesRef); }