query a line sketch

papawo
papawo Member, Developers Posts: 206 PRO
how can i query a line and get or save  its coordinates or info?

Comments

  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,279 image
    If you have a query for a line, for instance if you know the sketch has only one thing in it and you do lineQuery = qCreatedBy(id + "mySketch", EntityType.EDGE) then evLine(context, { "edge" : lineQuery }) will return a Line (which has origin and direction coordinates).
    See:
    https://cad.onshape.com/FsDoc/library.html#evLine-Context-map
    https://cad.onshape.com/FsDoc/library.html#Line
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • papawo
    papawo Member, Developers Posts: 206 PRO
    how to capture line & line 2 without user selecting it?

  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,279 image
    I don't quite understand what you mean here -- I assume you want to query for the two lines. So what are you starting with? A sketch (and you want to query for all lines in it)? A vertex? A query for some other entity/entities?
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • papawo
    papawo Member, Developers Posts: 206 PRO
    lets just say i just created a polygon sketch with 6 sides and i want to query & capture line[1],line[2] ..or vertex [1], vertex [2] ....without  the user help?
  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,279 image
    Sorry, I'm still not clear: when you say "I just created a polygon," do you mean in an interactive sketch (i.e., by clicking the sketch button in a part studio and dragging out the polygon with the polygon tool), do you mean in FeatureScript with like skPolygon earlier in the same feature, or do you mean in a prior custom feature?  If it's earlier in the same feature, you can use sketchEntityQuery (https://cad.onshape.com/FsDoc/library.html#sketchEntityQuery-Id--string) with the entity id of the relevant line or vertex.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • papawo
    papawo Member, Developers Posts: 206 PRO
    this FS is based on the tutorial using skRectangle. user has to pick line 1,2 & 3 to create rectangle then extrude & subtract the part since those lines varies .  line 1 will create rectangle and subtract, then line 2 will do the same then line 3 too..
    what im trying to achieved is after it create 1 rectangle , i need to fillet one of its corner (say the upper corner of the rectangle "a" ). then extrude and subtract the part.
    So I was thinking , to id the 2 lines of the rectangle . I dont know if its correct approach though is there an easier way to do it?