docs.unity3d.com
Version: 

    Part

    API reference

    Parts are components that contain geometry information, such as information related to CAD, meshes, lines, and UVs. "Part occurrences" is a term often used to refer to occurrences containing part components.

    Part properties:

    Property Type Description
    Id Ident A unique unsigned int identifier
    BRepShapeInitial Entity Original CAD geometry data before tessellation
    BRepShapeModified Entity
    TessellatedShape Entity Mesh information
    Transform Matrix4 Local transform matrix of this part component, storing local position, rotation and scale information
    Tip

    Use scene.getPartOccurrences(root) to retrieve all part occurrences under the root occurrence.

    Use definitions to retrieve geometry information from a Part component. This example shows how to retrieve the position of vertices of a mesh (Mesh) through its definition (MeshDefinition):

    • Python
    • C#
    part = pxz.scene.getComponent(occurrence, pxz.scene.ComponentType.Part)
    # "part == 0" means that the occurrence doesn't have a part component.
    if (part > 0)
    {
        mesh = pxz.scene.getPartMesh(part)
        # "mesh == 0" means that no mesh is attached to the part.
        if (mesh > 0)
        {
            # Queries geometry information from meshes.
            meshDef = pxz.polygonal.getMeshDefinition(mesh)
            vertices = meshDef.vertices
            # …
        }
    }
    
    uint part = pxz.Scene.GetComponent(occurrence, Scene.Native.ComponentType.Part);
    // "part == 0" means that the occurrence doesn't have a part component.
    if (part > 0)
    {
        uint mesh = pxz.Scene.GetPartMesh(part);
        // "mesh == 0" means that no mesh is attached to the part.
        if (mesh > 0) 
        {
            // Queries geometry information from meshes.
            Polygonal.Native.MeshDefinition meshDef = pxz.Polygonal.GetMeshDefinition(mesh); 
            Geom.Native.Point3List vertices = meshDef.vertices;
            // …
        }
    }
    

    To duplicate a part, use the core.cloneEntity method. This snippet shows how to create a new occurrence that shares the same part component as its input:

    • Python
    • C#
    # Gets the components to be duplicated.
    partComponent = pxz.scene.getComponent(occ, pxz.scene.ComponentType.Part)
    
    # Creates an occurrence.
    lod = pxz.scene.createOccurrence("_LOD1")
    
    # Sets the part component of the cloned occurrence as the part component of the new occurrence.
    pxz.scene.setComponentOccurrence(pxz.core.cloneEntity(part), lod)
    pxz.scene.setParent(lod, occ)
    
    // Gets the components to be duplicated.
    uint partComponent = pxz.Scene.GetComponent(occ, Scene.Native.ComponentType.Part);
    
    // Creates an occurrence.
    uint lod = pxz.Scene.CreateOccurrence("_LOD1");
    
    // Sets the part component of the cloned occurrence as the part component of the new occurrence.
    pxz.Scene.SetComponentOccurrence(pxz.Core.CloneEntity(part), lod);
    pxz.Scene.SetParent(lod, occ);
    

    Version 2024.2.2.3
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX.