Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Examples of functional code of simple small operations.( Feature_Script)

FdaFda Member Posts: 42 ✭✭
Hello, I'm new with this Feature_Script, and I can not hole a geometry.

Before putting this post I tried to find an example.

The documentation of Feature_Script is confusing to me.

As a user I am missing examples of functional code of simple small operations. 

It would be wonderful if these examples were discussed in detail.

If somebody is amabel to give an example of how to hole a geometry.

Thanks for your time



///
Hola, soy nuevo con esto de Feature_Script, y no consigo remover una geometría. 

Antes de poner este post he intentado encontrar algún ejemplo. 

La documentación de Feature_Script me resulta algo confusa.

 ejemplos de cogido funcional de pequeñas operaciones simples. 

Seria maravilloso que estos ejemplos estuvieran comentados con detalle. 

Para una fácil introducción en Feature_Script.

Si alguin estan amabel de poner un ejemplo de como remover  una una geometria.

Gracias por su tiempo

//


Tagged:

Comments

  • mahirmahir Member, Developers Posts: 1,291 ✭✭✭✭✭
    The easiest way to get example code is to find a feature that does something similar and look at its code. Even the standard functions (like Hole or Extrude) are written using the same FeatureScript language that is available to all users.

    La forma más fácil de obtener un ejemplo de código es encontrar un funcion que haga algo similar a que quieres y mirar su código. Incluso las funciones estándar (como Hole o Extrude) se escriben utilizando el mismo lenguaje de FeatureScript que está disponible para todos los usuarios.
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,173
    @mahir
    Our hole and extrude are two very complicated features.  I would suggest starting with the tutorials here: https://cad.onshape.com/FsDoc/tutorials/create-a-slot-feature.html -- it is a simple, guided way of essentially poking a hole in a part.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • FdaFda Member Posts: 42 ✭✭
    mahir said:
    The easiest way to get example code is to find a feature that does something similar and look at its code. Even the standard functions (like Hole or Extrude) are written using the same FeatureScript language that is available to all users.

    La forma más fácil de obtener un ejemplo de código es encontrar un funcion que haga algo similar a que quieres y mirar su código. Incluso las funciones estándar (como Hole o Extrude) se escriben utilizando el mismo lenguaje de FeatureScript que está disponible para todos los usuarios.

    Believe me I have already searched, I saw the 1 hour Webinar video of

    https://youtu.be/KVX1xq5UQy0

    But I am stuck with something that is simple. A sinple drill.
    1) - I'm looking for a way to make a sketch.
    2) - Make a revolution operacon generate a drill in a solid.
    3) - Without the user choosing the point of the revolution. (a constant operation)

    Créeme ya he buscado, vi el video Webinar  de 1 hora de 
    Pero estoy atascado con algo que es simple. Un simple taladro. 
    1) - Busco la manera de hacer un croquis.
    2 ) - Hacer una operacon de revolucion generar un taladro en un solido.
    3) - Sin que el usuario elija el punto de la revolucion. (una operacion contante)

    
    
    revolve(context, sketch21 + "revolve", {
       "operationType" : NewBodyOperationType.REMOVE,
       "entities" : qUnion([sketch21]),
       //"axis" : qUnion([axisQuery]),
       "axis" : qUnion(["line1"]),
       "revolveType" : RevolveType.FULL,
       "defaultScope" : true });
    
    

    subtract geometry with extrusion

    annotation { "Feature Type Name" : "My 1235" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            // Define the parameters of the feature type
        }
        {
                   
            var eje1 = 40; //x
            var eje2 = 150; // y
            var eje3 = 50;
            
            // Define the function's action
            var sketch1 = newSketch(context, id + "sketch1", {
                    "sketchPlane" : qCreatedBy(makeId("Front"), EntityType.FACE)
            });
    
            skLineSegment(sketch1, "line1", {
                    "start" : vector(-(eje1/2), 0) * millimeter,
                    "end" : vector(-(eje1/2), eje2) * millimeter
            });
            
            skLineSegment(sketch1, "line2", {
                    "start" : vector(-(eje1/2), 0) * millimeter,
                    "end" : vector((eje1/2), 0) * millimeter
            });
    
            skLineSegment(sketch1, "line3", {
                    "start" : vector(-(eje1/2), eje2) * millimeter,
                    "end" : vector(eje1/2, eje2) * millimeter
            });      
             
            skLineSegment(sketch1, "line4", {
                    "start" : vector((eje1/2), 0) * millimeter,
                    "end" : vector((eje1/2), eje2) * millimeter
            });
    
            
            skSolve(sketch1);
            
            opExtrude(context, id + "extrude1", {
                    "entities" : qSketchRegion(id + "sketch1"),
                    "direction" : evPlane(context, {"face" : qSketchRegion(id + "sketch1")}).normal,
                    //"oppositeDirection" : 
                    "endBound" : BoundingType.BLIND,
                    "endDepth" : 50
            });
        });
    




  • FdaFda Member Posts: 42 ✭✭
    @mahir
    Our hole and extrude are two very complicated features.  I would suggest starting with the tutorials here: https://cad.onshape.com/FsDoc/tutorials/create-a-slot-feature.html -- it is a simple, guided way of essentially poking a hole in a part.

    I think you need to add more examples, just one example is not enough.
    Update videos -> FeatureScript | Webinar
    Surprisingly today I created a macro. but I still have to drill the holes in the pieces that the FeatureScript macro generates.

    Creo que hace falta añadir más ejemplos, un solo ejemplo no es suficiente. 
    Actualizar los videos -> FeatureScript | Webinar
    Sorprendente mente hoy he creado una macro. pero me falta hacer los taladros en la piezas que genera la macro FeatureScript.
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 858 ✭✭✭✭✭
    Hola @fermin_fermin_1

    Onshape tiene numerosos ejemplos de macros en FeatureScript

    Además de los ejemplos indicados en el vídeo que has citado o los tutoriales, "todos los comandos de Onshape" tienen su código en FeatureScript que puedes consultar en el documento std

    Por otra parte, tienes también numerosos ejemplos creados por otros usuarios, entre los que se incluyen algunas de nuestras macros:
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • FdaFda Member Posts: 42 ✭✭
    Hola Eduardo, precisamente antes de poner este post  he mirado he mirado tu código el de los colores, el cual esta comentado en castellano. 
    En dos días he llegado a crear esta macro, pero estoy atascado con lo de hacer taladros a los sólidos.https://youtu.be/XLYpnnCJBRk

    #Please, someone can give a simple example of how to make a hole
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 858 ✭✭✭✭✭
    Un par de consejos:
    • Antes de ponerte a crear código primero deberías pensar si es necesario.
    Por lo que puedo ver en el vídeo, puede que no necesites crear esa macro y deberías hacer algunas pruebas con configuraciones primero. Me parece que conseguirás el mismo resultado pero de forma más sencilla.
    • Primero define la interfaz de tu macro (UI) y cómo quieres que funcione.
    Por lo que se ve en el vídeo aún no tienes definido en la interfaz la información de los taladros. Aunque es posible que no necesites ninguna o que esté oculta.

    Tienes un ejemplo de una macro que hace taladros aquí Port feature

    Si estás haciendo la macro para aprender FeatureScript, perfecto. Ánimo, y comparte aquí algo del código si tienes dudas.
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
  • emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 858 ✭✭✭✭✭
    Y aquí otro ejemplo Pocket holes
    Un saludo,

    Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                         Partner de PTC - Onshape                                     Averigua a quién conocemos en común
Sign In or Register to comment.