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 PRO

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)


  • mahirmahir Member, Developers Posts: 1,081 ✭✭✭✭✭
    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).

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,015
    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 \ Director, Architecture and FeatureScript \ Onshape Inc
  • jason_bennett190jason_bennett190 Member, Developers Posts: 17 PRO
    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.
  • otaolafrotaolafr Member Posts: 107 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.

Sign In or Register to comment.