Objects change to layer. Help me

i want change layer for object is selected by code python but i can’t. EX: i have text and text dot in layer default. I select text and move them to new layer (add layer and move).
I dont know command of change layer for object. Please help me

That would be:

rs.ObjectLayer(objects, layername)

You might want to check to see if the layer “layername” exists first and if not, create it:

if not rs.IsLayer(layername): rs.AddLayer(layername)

Check the rhinoscriptsyntax help for more info, there are a number of optional arguments for rs.AddLayer() for example.

1 Like

Thank you! I have a rectangle form, i want to get point in the 4 angle and drawing path in which it should be doing any

Hi I’m sorry, but that’s not completely clear, can you explain in more detail?

–Mitch

i want get location of rectangle be draw before.

OK, let me try to walk through this with you.

You have an existing rectangle in Rhino? You want to find it’s “location”?

A rectangle is a polyline with 4 corner points, it has a start/end point and 3 points in between. Rhino objects do not have specific “center” or “pivot” point.

To get the start of a curve, use rs.CurveStartPoint(curve)
To get the end of a curve, use rs.CurveEndPoint(curve)
To get the midpoint of a curve, use rs.CurveMidPoint(curve)

To get the control points of a curve use rs.CurvePoints(curve) this will actually return five points, the start and the end of a closed curve are the same point.

If you are looking for a “center” of a rectangle, you can use rs.CurveAreaCentroid(curve)

Again, check the Help for more info on all of these methods.

Does any of the above answer what you need?

–Mitch

1 Like

Thank you.
how can i get all text dot inside closed curve?

I guess something like this will work:

import rhinoscriptsyntax as rs

#get the containing curve
container=rs.GetObject("Select planar containing curve",4)
if container:
    #make sure it's closed and planar
    if rs.IsCurveClosed(container) and rs.IsCurvePlanar(container):
        #get the curve plane
        plane=rs.CurvePlane(container)
        #get all visible/selectable dots in the file
        dots=rs.ObjectsByType(8192, state=1)
        if dots:
            inside=[]
            for dot in dots:
                #get dot insertion point
                pt=rs.TextDotPoint(dot)
                if rs.PointInPlanarClosedCurve(pt,container,plane):
                    #if true, dot is inside container curve, add to list
                    inside.append(dot)
            #if any dots are inside, they will be in the list "inside"
            if inside:
                rs.SelectObjects(inside)
            #the list 'inside' contains the ID's of the dots for further use

Note that as text dots are considered as points in this case, the script will select dots whose insertion point is inside the container, even of part of the dot itself is outside the container.

1 Like

Great!
have you document of python rhinoceros? I want to study but could not find document. Please send me if you have it. Thank a lot

Have a look at this page:

There is also the “Python 101 primer” here:
https://www.rhino3d.com/download/IronPython/5.0/RhinoPython101

–Mitch

2 Likes

I am trying to select multiple rows of blue lines to remove it without having to select them one by one. Is there any way

Hmm, maybe I’m colorblind, but in your image I only see yellow (gold) and green. What are you trying to select actually? Can you post a .3dm Rhino file as an example?

1 Like

I want to remove the green lines without having to select each line

Well you could select one green object, run SelColor which will select all other objects of the same color… then Delete.

1 Like

In fact when I do it in the same layer, the color image is just simulating I want to remove the green lines

Well again, please post a Rhino file with an example. If the green lines are fully enclosed by some other closed curves it might be possible to detect them via a script, but otherwise, it will be difficult.

1 Like

333.3dm (6.1 MB)

I am trying to delete closed inner lines without having to select individual paths to remove

Could you select all shapes and then delete those with more than 4 points?

1 Like

I can’t find that delete command anywhere, can you help me