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.


opTransform error in FeatureScript

jason_bennett190jason_bennett190 Member, Developers Posts: 17

I am trying to do an opTransform of type copy, but I am getting an error I don't understand. It seems like the error is saying that TransformType.COPY is a String and should not be a String, but it doesn't look like a string to me. Could someone tell me what I am doing wrong here?


This is my code:

<div>&nbsp;opTransform(context, id + "transform1", {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "transform" : TransformType.COPY,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "entities" : definition.part,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "makeCopy" : true</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br></div>

This is the error:

@opTransform: Map field 'transform' is of wrong type STRING
onshape/std/geomOperations.fs (opTransform)
Feature Studio 1 (const corePrint)

onshape/std/feature.fs (defineFeature)
Part Studio 1 (build)
Part Studio 1 (build)
Part Studio 1 (main)


  • Options
    mahirmahir Member, Developers Posts: 1,291 ✭✭✭✭✭
    edited September 2016
    The "transform" input of opTransform is an actual transform, not a TransformType. It's basically a 3x3 matrix describing scaling/rotation/translation or a 3 element vector describing just translation. There are several functions that will generate a transform object for you (see the examples below).

  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,175
    To add to Mahir's answer, if you want to copy a part in place, use opPattern and pass an array consisting of one identity transform.  Or if you just write "transform" instead of "opTransform" and use your existing arguments, that will invoke the transform feature instead of the operation and that should do what you expect (just with a bit more overhead than opPattern).
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    jason_bennett190jason_bennett190 Member, Developers Posts: 17
    Thanks to both of you. Mahir's answer got me most of the way there with a little bit of head scratching, and ilya's contribution got me the rest of the way.
  • Options
    otaolafrotaolafr Member Posts: 113 EDU
    I am looking all over the forum to find a good complete example with opPattern, I can not understand how to use it, I am trying to choose an object and then pattern in a list of vectors in the 3D space (not only a direction more like a "cloud" of points). From the feedback and answers from questions, I saw that opPattern would be a good idea.... but from the standard documentation (https://cad.onshape.com/FsDoc/library.html#opPattern-Context-Id-map) I can not get how to use it.
    you guys are super helpful each time I am looking for help to do something you help me, but I would really like to look in the documentation to don't fill up the forum with my issues (and be a little bit independent ahahaha) is something I am missing!? like a formation or something?
    thanks either way.

  • Options
    jelte_steur814jelte_steur814 Member Posts: 77 PRO
    edited March 19
    for those after that still don't understand from above. I've finally figured out how to make a copy in place of an entity in Featurescript using opPattern. It's not hard looking back at it, but for a newb like me, figuring it out still took a long time.

    This is wat worked for me:

            const instanceNames = ["Copy1"];
            const transforms = [identityTransform()];  //empty tranform tocopy in place. string in array
            opPattern(context, id + "pattern1", {
                    "entities" : definition.targets,
                    "transforms" : transforms,
                    "instanceNames" : instanceNames

    good luck!

Sign In or Register to comment.