Quantcast
Channel: Scripting - McNeel Forum
Viewing all 4120 articles
Browse latest View live

Split script creating unwanted surfaces, how to delete within script?

$
0
0

@kleerkoat wrote:

i have a script here that splits objects by the construction plane. when i split a solid the script sometimes creates a planar surface that i don’t want. (possible bug?)

is there a way within the script to have it filter the output and delete those surfaces?

the function are called SplitObjectsWithLine but it actually uses the cplane, i just haven’t cleaned it up yet

"""Splits selected objects with the CPlane of the active viewport. 
Objects can be curves, surfaces, polysurfaces or meshes.
Script by Mitch Heynick version 29.01.17."""

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def FixDegenerateBB(bb,plane,tol):
    #expands degenerate (0 length side) bounding box in the required direction(s)
    #returns fixed bounding box or original if nothing needs to be done
    if bb[1].DistanceTo(bb[2])<tol:
        t_vec=plane.YAxis
        bb[2]+=t_vec ; bb[3]+=t_vec ; bb[6]+=t_vec ; bb[7]+=t_vec
        bb[0]-=t_vec ; bb[1]-=t_vec ; bb[4]-=t_vec ; bb[5]-=t_vec
    if bb[0].DistanceTo(bb[1])<tol:
        t_vec=plane.XAxis
        bb[1]+=t_vec ; bb[2]+=t_vec ; bb[5]+=t_vec ; bb[6]+=t_vec
        bb[0]-=t_vec ; bb[3]-=t_vec ; bb[4]-=t_vec ; bb[7]-=t_vec
    if bb[0].DistanceTo(bb[4])<tol:
        t_vec=plane.ZAxis
        bb[4]+=t_vec ; bb[5]+=t_vec ; bb[6]+=t_vec ; bb[7]+=t_vec
        bb[0]-=t_vec ; bb[1]-=t_vec ; bb[2]-=t_vec ; bb[3]-=t_vec
    return bb

def SplitObjsWithLine():
    msg="Select curves, surfaces or meshes to split with CPlane"
    objIDs=rs.GetObjects(msg,4+8+16+32,preselect=True)
    if not objIDs: return
    
    tol=sc.doc.ModelAbsoluteTolerance
    cut_plane=rs.ViewCPlane()
    sf=1.1 #scale factor for enlarging cut plane - can be changed
    #principal problem from here is can't split breps or meshes with plane object
    #need to create a planar *surface* or *mesh* to use as cutter
    
    #create cutting objects
    #get objs bb relative to cutting plane
    bb=rs.BoundingBox(objIDs,cut_plane)
    #need to expand 0 length sides to work with completely planar situations
    bb=FixDegenerateBB(bb,cut_plane,tol)
    #create planar projection to cut plane
    xform_cut=rs.XformPlanarProjection(cut_plane)
    #create bb bottom rectangle(points), project to cut plane
    corners=rs.PointArrayTransform([bb[0],bb[1],bb[2],bb[3],bb[0]],xform_cut)
    #get center point for uniform scale 
    ctr_pt=(corners[0]+corners[2])/2
    #create cutting plane rectangle
    cut_rect=Rhino.Geometry.PolylineCurve(corners)
    #scale rectangle a bit larger to ensure full cut
    xform_scale=Rhino.Geometry.Transform.Scale(ctr_pt,sf)
    cut_rect.Transform(xform_scale)
    
    #create plane brep for cutter
    cut_srf=Rhino.Geometry.Brep.CreatePlanarBreps(cut_rect)[0]
    #create mesh plane for cutter
    mp=Rhino.Geometry.MeshingParameters.Coarse
    cut_mesh=Rhino.Geometry.Mesh.CreateFromPlanarBoundary(cut_rect,mp)
    #sc.doc.Objects.AddBrep(cut_srf)  #debug
    #sc.doc.Objects.AddMesh(cut_mesh)  #debug
    #sc.doc.Views.Redraw() ; return  #debug
    
    #main loop
    rs.EnableRedraw(False)
    split_result=[]
    no_split=0
    for objID in objIDs:
        rhobj=rs.coercerhinoobject(objID,True,True)
        attrs=rhobj.Attributes
        obj=rhobj.Geometry
        if rs.IsCurve(objID):
            split_res=obj.Split(cut_srf,tol)
            if split_res:
                for crv in split_res:
                    split_result.append(sc.doc.Objects.AddCurve(crv,attrs))
                rs.DeleteObject(objID)
            else: no_split+=1
        elif rs.IsBrep(objID):
            if isinstance(obj,Rhino.Geometry.Extrusion):
                if obj.HasBrepForm:
                    obj=obj.ToBrep()
                else:
                    no_split+=1 ; continue
            split_res=Rhino.Geometry.Brep.Split(obj,cut_srf,tol)
            if split_res:
                for brep in split_res:
                    cap=brep.CapPlanarHoles(tol)
                    if cap: brep=cap
                    split_result.append(sc.doc.Objects.AddBrep(brep,attrs))
                rs.DeleteObject(objID)
            else: no_split+=1
        elif rs.IsMesh(objID):
            split_res=Rhino.Geometry.Mesh.CreateBooleanSplit([obj],[cut_mesh])
            if split_res:
                for mesh in split_res:
                    split_result.append(sc.doc.Objects.AddMesh(mesh,attrs))
                rs.DeleteObject(objID)
            else: no_split+=1
            
    #reporting
    if split_result:
        splits=len(objIDs)-no_split
        if splits>1: s="s"
        else: s=""
        msg="{} object{} split into {} parts.".format(splits,s,len(split_result))
        if no_split>0: msg+=" {} objects unable to be split".format(no_split)
        #rs.SelectObjects(split_result) #optional
    else:
        msg="No objects were split"
    print msg
SplitObjsWithLine()

Posts: 1

Participants: 1

Read full topic


Layers in Phython Scripting

$
0
0

@miano wrote:

This is a script that someone kindly provided an outline for me and I have have cleaned up—that still needs work. The objective of the script is to import a CSV file containing layer names. It is supposed to read the file. If it finds a string, it is to create a new layer below the current layer. If finds a value, it is to add a point in the last created layer.

The problem is that the script creates new layers in a mixture of locations. It seems to create some layers below the current layer and some layers at the root.

Why would that be?

I think I have a lack of understanding on how layers work the python interface. The CurrentLayer() function returns a string. How can I distinguish between "Abc"s with a layer structure like this:

Layer 1
     Abc
Layer 2
   Abc

Script:

import Rhino
import csv
import rhinoscriptsyntax as rs
import random


def importtolayers():

    file = rs.OpenFileName(filter = "CSV files|*.csv|Text files|*.txt||", extension = ".csv")
     
    with open(file, "rU") as f:
        reader = csv.reader (f, dialect=csv.excel)
        parentlayer = rs.CurrentLayer ()
        
        layer = parentlayer
        print "Root Layer: ", parentlayer
        for line in reader:
            value = line[0].strip () ;
            try:
                if value <> "":
                    float (value)
                    x = rs.AddPoint(rs.Str2Pt(line))
                    if x: rs.ObjectLayer(x, layer)
                
            except ValueError:
                print "New Layer ", value ;
                color = rs.CreateColor (random.randint (0, 255), random.randint (0, 255), random.randint (0, 255))
                layer = rs.AddLayer(value, color=color, parent=parentlayer)
importtolayers()

Posts: 2

Participants: 2

Read full topic

Rhinoscript - Centroid of curve

$
0
0

@rhorsefield wrote:

I am writing a Rhinoscript weight estimating program. One part of the program will use curve lengths and centroids to calculate pipe weights/centers. Each curve is assumed to be the same pipe diameter. The centroid in this case is not the same as the midpoint of the curve. The only way I can see to do this is to temporarily wrap a pipe around the curve, interrogate it’s centroid, then delete the pipe. I’m starting with a known curve object. My untested code is a follows:

Dim arrDomain
Dim arrCentroid
arrDomain = Rhino.CurveDomain(strCrvObject)
strTempPipeObject = rhino.AddPipe(strCrvObject, Array(arrDomain(0)), Array(4), 1, 0, True)
arrCentroid = Rhino.SurfaceAreaCentroid(strTempPipeObject)
Rhino.DeleteObject strTempPipeObject, True

Is there a simpler way to do this that I’m not seeing?

Posts: 2

Participants: 2

Read full topic

Path mapping in c#

$
0
0

@daniel.c wrote:

Hi,

Im trying to step up game and after producing some very basic scripts in python Im trying c#. Anyways, 2 questions:

Grid of points.gh (5.9 KB)

  • I would welcome any tips to simplify my messy c# script producing grid of points according to input lists of distances in X, Y coordinates.
// Create list for points
Rhino.Collections.Point3dList PtList = new Rhino.Collections.Point3dList();

// Variable for loops
double xx = 0;
double yy = 0;

// List for X and Y distance values
List<double> ListXX = new List<double>();
List<double> ListYY = new List<double>();

// Add 0 coordinates to lists X, Y
ListXX.Add(0);
ListYY.Add(0);


//Loop to create List of X coordinates
for (var i = 0; i < x.Count; i++)
{
  xx = xx + x[i];
  ListXX.Add(xx);
}

//Loop to create List of Y coordinates
for (var i = 0; i < y.Count; i++)
{
  yy = yy + y[i];
  ListYY.Add(yy);
}

// Loop to generate points
for (var i = 0; i < ListXX.Count; i++)
{
  for (var j = 0; j < ListYY.Count; j++)
  {
    PtList.Add(ListXX[i], ListYY[j], 0);
  }
}


// Outputs
A = ListXX;
B = ListYY;
C = PtList;

Regards,
Dan.

Posts: 2

Participants: 2

Read full topic

Set Name of Detail View

$
0
0

@eric.bunn wrote:

Hi,

I got this block of code from Djordje Spasic and I’m wondering how one might go about giving a name to the detail views in a layout. Djordje was nice enough to give me the code below and when you run it the detail views come up empty since they are not assigned.

This is the code to cycle through the detail views:

def GetAllDetailViews():
    pageView_L = Rhino.RhinoDoc.ActiveDoc.Views.GetPageViews()
    
    for pageView in pageView_L:
        print "pageView.PageName: ", pageView.PageName
        detailView_L = pageView.GetDetailViews()
        for detailView in detailView_L:
            print "detailView.Name: ", detailView.Name

Thanks in advance for the help.

Eric

Posts: 6

Participants: 2

Read full topic

Extract numbers from Text

Inputs and outputs of component

Get Current Detail Scale

$
0
0

@eric.bunn wrote:

Hi,

I’ve been successful using DetailGeometry.SetScale to set the scale of a detail. How can you get the current scale of the detail before you run DetailGeometry.SetScale so you can do some math on it first based on the current scale.

Python by the way using Rhino 5 or 6.

Eric

Posts: 3

Participants: 2

Read full topic


Rhino.getobject, subobject toggle not working

$
0
0

@kleerkoat wrote:

i have a script here that i’m trying to get subobject select working.

per documentation:

GetObject(message=None, filter=0, preselect=False, select=False, custom_filter=None, subobjects=False)

but in autocomplete it’s not showing

Option Explicit
'Script written by Pascal
' RMA
'Script version Tuesday, December 06, 2011

'Rhino.AddStartUpScript Rhino.LastLoadedScriptFile
'Rhino.AddAlias "FinAngle", "_NoEcho _-Runscript (FinAngle)"

Private oldLen, oldAng

If isEmpty(oldlen) Then
	OldLen = 1
End If


If isEmpty(oldang) Then
	OldAng = 10
End If

'Call FinAngle()

Sub FinAngle()
	' Dim sCrv: sCrv = Rhino.GetObject("Select curve", 4, True)
	Dim sCrv: sCrv = Rhino.GetObject("Select curve", 4, True, , , True)
	If isNull(sCrv) Then Exit Sub
	Dim BlnCLosed: blnClosed = False
	If Rhino.IsCurveClosed(sCrv) Then
		blnClosed = True
	End If
	'Dim sSrf : SSrf = Rhino.GetObject("Select base surface.", 8)
	Dim sSrf : SSrf = Rhino.GetObject("Select base surface.", 8, , , True)
	If isNull(sSrf) Then Exit Sub

	Dim dblAng, dblLen

	dblAng = Rhino.getreal("Fin angle.", oldAng, 0, 90)
	If isNull(dblANg) Then Exit Sub
	OldAng = dblAng

	dbllen = Rhino.getreal("Fin depth.", oldlen, 10 * Rhino.UnitAbsoluteTolerance())
	If isNull(dblLen) Then Exit Sub
	OldLen = dblLen

	Dim aEdit: aEdit = Rhino.CullDuplicatePoints(Rhino.CurveEditPoints(sCrv))
	Dim apar: apar = Rhino.CullDuplicateNumbers(Rhino.CurveEditPoints(sCrv, True))


	Dim aLines, blnFlip, aItems, aDef, n, Flipped
	aItems = array("FlipAngle", "No", "Yes", "FlipNormal", "No", "Yes")
	adef = array(False, False)
	n = 0
	Flipped = 0
	Dim tempsrf, intAng
	intAng = 1

	Do
		If n <> 0 Then Rhino.DeleteObjects tempSrf

		aLines = AddLines(sCrv, sSrf, aEdit, aPar, dblLen, dblang)
		If Rhino.IsCurveClosed(sCrv) Then
			tempSrf = makeSrf(alines, blnClosed)

		Else
			tempSrf = makeSrf(alines, blnClosed)

		End If

		blnFlip = Rhino.GetBoolean("Set options:", aItems, aDef)
		If Not isArray(blnFlip) Then Exit Sub

		If BlnFlip(0) = True Then

			dblAng = -dblAng
			intAng = 2
		Else
			intAng = 1
		End If


		If BlnFlip(1) = True Then
			If intAng = 1 Then dblAng = -dblAng
			Rhino.UnselectAllObjects()
			Rhino.SelectObject sSrf
			Rhino.Command "_Dir _Flip _Enter "
			Rhino.UnselectAllObjects()
			If Flipped = 0 Then
				Flipped = 1
			Else
				Flipped = 0
			End If

		End If


		n = n + 1
	Loop While blnFlip(0) + BlnFlip(1) <> 0


	If Flipped = 1 Then
		Rhino.Enableredraw  False
		Rhino.UnselectAllObjects()
		Rhino.SelectObject sSrf
		Rhino.Command "_Dir _Flip _Enter "
		Rhino.Enableredraw  True
	End If

	Rhino.DeleteObjects aLines

End Sub


Function makeSrf(alines, blnClosed)

	Dim tempSrf
	If BlnClosed Then
		tempSrf = Rhino.AddLoftSrf(aLines,,,,,, True)

	Else
		tempSrf = Rhino.AddLoftSrf(aLines,,,,,, False)

	End If
	Rhino.DeleteObjects aLines
	makeSrf = tempSrf
End Function

Function AddLines(sCrv, sSrf, aPts, aPar, dbllen, dblang)
	Rhino.EnableRedraw False
	Dim aLines, edit_pt, start_par, n, vecnorm, plane
	n = 0
	ReDim alines(Ubound(aPts))

	For Each edit_pt In aPts

		start_par = Rhino.SurfaceClosestPoint(sSrf, edit_pt)
		Vecnorm = Rhino.VectorScale(Rhino.SurfaceNormal(sSrf, start_par), dblLen)

		plane = Rhino.CurveperpFrame(sCrv, apar(n))
		aLines(n) = Rhino.AddLine(edit_Pt, Rhino.PointAdd(edit_pt, vecnorm))

		Rhino.RotateObject aLines(n), plane(0), dblang, plane(3)
		n = n + 1

	Next
	AddLines = aLines
	Rhino.EnableRedraw True
End Function

Posts: 6

Participants: 2

Read full topic

Simple macro

$
0
0

@Mikey wrote:

Being trying to set up the FBX import in Modo so it could change the vertical Rhino’s Z-axis to Modo’s Y-axis but so far it works not exactly how I want it to. Please help to make a simplest macro line in Rhino for silent process so I could add that line here:

_ROTATE X-Axis -90deg (???)
_-Export Pause “D:\rhino2modo.fbx” Enter Enter

Here automation is about to use FBX temporary file as a translator : )

Posts: 5

Participants: 3

Read full topic

Userform in Rhino 6 Opens Half the Size

$
0
0

@eric.bunn wrote:

Hi,

I have a user on Rhino 6 that is having problems with how a userform is displayed on their machine. I sent them a simple test userform to try and troubleshoot this and the userform opens up about half the size and all of the controls get crammed together. They also have a version of Rhino 5 and it opens fine on the same machine. I can open it on my machine in 5 or 6 with no problem. Anyone seen this before and any and all suggestions are appreciated.

I’ve posted the code below. This came from SharpDevelop with some modifications.

Eric

805f145a-7057-410e-9ac0-fba6910ac435 UF V 5

import System.Drawing
import System.Windows.Forms

from System.Drawing import *
from System.Windows.Forms import *

mbl = 30

class MainForm(Form):
def init(self):
self.InitializeComponent()

def InitializeComponent(self):
	self._numericUpDown1 = System.Windows.Forms.NumericUpDown()
	self._groupBox1 = System.Windows.Forms.GroupBox()
	self._label1 = System.Windows.Forms.Label()
	self._lblTitle = System.Windows.Forms.Label()
	self._checkBox1 = System.Windows.Forms.CheckBox()
	self._checkBox2 = System.Windows.Forms.CheckBox()
	self._numericUpDown2 = System.Windows.Forms.NumericUpDown()
	self._numericUpDown1.BeginInit()
	self._groupBox1.SuspendLayout()
	self._numericUpDown2.BeginInit()
	self.SuspendLayout()
	# 
	# numericUpDown1
	# 
	self._numericUpDown1.DecimalPlaces = 3
	self._numericUpDown1.Increment = System.Decimal(System.Array[System.Int32](
		[5,
		0,
		0,
		65536]))
	self._numericUpDown1.Location = System.Drawing.Point(132, 19)
	self._numericUpDown1.Name = "numericUpDown1"
	self._numericUpDown1.Size = System.Drawing.Size(120, 20)
	self._numericUpDown1.TabIndex = 0
	self._numericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
	self._numericUpDown1.Value = System.Decimal(System.Array[System.Int32](
		[24,
		0,
		0,
		0]))
	self._numericUpDown1.ValueChanged += self.NumericUpDown1ValueChanged
	# 
	# numericUpDown2
	# 
	self._numericUpDown2.Location = System.Drawing.Point(133, 42)
	self._numericUpDown2.Name = "numericUpDown2"
	self._numericUpDown2.Size = System.Drawing.Size(139, 20)
	self._numericUpDown2.TabIndex = 4
	self._numericUpDown2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
	self._numericUpDown2.Value = System.Decimal(System.Array[System.Int32](
		[24,
		0,
		0,
		0]))
	self._numericUpDown2.ValueChanged += self.NumericUpDown2ValueChanged
	# 
	# groupBox1
	# 
	self._groupBox1.Controls.Add(self._checkBox2)
	self._groupBox1.Controls.Add(self._label1)
	self._groupBox1.Controls.Add(self._numericUpDown1)
	self._groupBox1.Location = System.Drawing.Point(13, 97)
	self._groupBox1.Name = "groupBox1"
	self._groupBox1.Size = System.Drawing.Size(259, 96)
	self._groupBox1.TabIndex = 1
	self._groupBox1.TabStop = False
	self._groupBox1.Text = "groupBox1"
	# 
	# label1
	# 
	self._label1.Location = System.Drawing.Point(17, 20)
	self._label1.Name = "label1"
	self._label1.Size = System.Drawing.Size(109, 19)
	self._label1.TabIndex = 1
	self._label1.Text = "Update MB L"
	self._label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
	# 
	# lblTitle
	# 
	self._lblTitle.Location = System.Drawing.Point(13, 9)
	self._lblTitle.Name = "lblTitle"
	self._lblTitle.Size = System.Drawing.Size(126, 23)
	self._lblTitle.TabIndex = 2
	self._lblTitle.Text = "Test Form"
	self._lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
	# 
	# checkBox1
	# 
	self._checkBox1.Checked = True
	self._checkBox1.CheckState = System.Windows.Forms.CheckState.Checked
	self._checkBox1.Location = System.Drawing.Point(133, 12)
	self._checkBox1.Name = "checkBox1"
	self._checkBox1.Size = System.Drawing.Size(139, 24)
	self._checkBox1.TabIndex = 3
	self._checkBox1.Text = "checkBox1"
	self._checkBox1.UseVisualStyleBackColor = True
	# 
	# checkBox2
	# 
	self._checkBox2.Checked = True
	self._checkBox2.CheckState = System.Windows.Forms.CheckState.Checked
	self._checkBox2.Location = System.Drawing.Point(132, 45)
	self._checkBox2.Name = "checkBox2"
	self._checkBox2.Size = System.Drawing.Size(120, 24)
	self._checkBox2.TabIndex = 4
	self._checkBox2.Text = "checkBox2"
	self._checkBox2.UseVisualStyleBackColor = True
	# 
	# MainForm
	# 
	self.ClientSize = System.Drawing.Size(284, 205)
	self.Controls.Add(self._numericUpDown2)
	self.Controls.Add(self._checkBox1)
	self.Controls.Add(self._lblTitle)
	self.Controls.Add(self._groupBox1)
	self.Name = "MainForm"
	self.Text = "Test"
	self._numericUpDown1.EndInit()
	self._groupBox1.ResumeLayout(False)
	self._numericUpDown2.EndInit()
	self.ResumeLayout(False)
	
	
#THIS ROUTINE WILL FIND A CONTROL AND UPDATE IT WITH MACRO DEFINED DATA
def UpdateUI(self,cName,cVal):
    for i in self.Controls:
        #Get Type
        fType = type(i)
        #Find Control on Main Form
        #Labels
        if i.Name == cName and fType == Label:
            i.Text = cVal
        #Checkboxes
        if i.Name == cName and fType == CheckBox:
            i.Checked = cVal
        # Numeric UpDown
        if i.Name == cName and fType == NumericUpDown:
            i.Value = cVal
            
        #Find Control in Group Box
        if fType == GroupBox:
            for j in i.Controls:
                #Get Type
                gType = type(j)
                # Numeric UpDown
                if j.Name == cName and gType == NumericUpDown:
                    j.Value = cVal	
                #Labels
                if j.Name == cName and gType == Label:
                    j.Text = cVal	
                #Checkboxes
                if j.Name == cName and gType == CheckBox:
                    j.Checked = cVal


def NumericUpDown1ValueChanged(self, sender, e):
	self._numericUpDown1 = sender.Value
	self.UpdateUI("numericUpDown1",mbl)
	self.UpdateUI("lblTitle","Changed1")
	self.UpdateUI("label1","Changed2")
	self.UpdateUI("checkBox1",False)
	self.UpdateUI("checkBox2",False)

def NumericUpDown2ValueChanged(self, sender, e):
	self._numericUpDown1 = sender.Value
	self.UpdateUI("numericUpDown2",mbl)

def DoSomething():
form = MainForm()
if form.ShowDialog() == System.Windows.Forms.DialogResult.OK:
print(form._numericUpDown1)
else:
print(“Canceled”)

if name==“main”:
DoSomething()

Posts: 7

Participants: 2

Read full topic

Rhinoscript: Set Layer Visibility per Detail

$
0
0

@Brayton_Orchard wrote:

Is there a Rhinoscript method to set layer visibility on a per-detail basis in layouts? I can’t find this in the online documentation, and I see that there is a method available in Rhinocommon: Layer.SetPerViewportVisible (I’m very new to scripting, but Rhinocommon actions do not transfer to Rhinoscript, correct?) Thanks.

Posts: 1

Participants: 1

Read full topic

Pickle in c#

Ghpythonremote and rhino3dm

List layout page names?

$
0
0

@petumatr wrote:

Hi folks,
do you think there is any chance to fish out the layout names and list it / export it? I need to create a drawing list and looking for a more convenient way :slight_smile:

Posts: 3

Participants: 2

Read full topic


Future of Grasshopper plugins development for Rhino 7 WIP in Python

$
0
0

@w.radaczynski wrote:

Hello guys :slight_smile:

Is it possible now to create large Grasshopper plugins with CPython using rhino.inside only? Are there any simple examples, so we can see it in action?

I’m aware of two existing plugins: GH Python Remote and GH_CPython - both can help to make some components, but it will be a huge difference, if we could easly create large plugins “outside” Rhino (using Pycharm/Visual Studio/Atom).

Posts: 1

Participants: 1

Read full topic

Copy Objects in Group and Remove Copies From Group

$
0
0

@eric.bunn wrote:

Hi

I’m selecting a group of objects with GetObjects using Python in Rhino 5, copying the objects using CopyObjects and finding that the copies are within the group I’ve selected. I want to remove them from the group and put them into their own group. I need a way to pull the group name from the selection so I can extract them from the group.

Thanks.

Eric

Posts: 1

Participants: 1

Read full topic

Rs.filter for subD object

$
0
0

@vincentfs wrote:

Hi everyone,

For rhinoscriptsyntax/Rhinocommon, is there an updated documentation I can refer to when dealing with subD object? I am current using rs.Command() as a makeshift for my scripts, but it is not very scripting friendly. I want to make my script as backwards compatible as possible. Any suggestions?

Best,
Vincent

Posts: 4

Participants: 2

Read full topic

More question about command InterpCrvOnSrf

$
0
0

@1792927545 wrote:

when I use the ‘_InterpCrvOnSrf’ command, it can span the seams of closed surfaces. But when I use the python script “rs.AddInterpCrvOnSrf( surface_id, [point1, point2])”, it will avoid the seam of the surface. I have tried the plugin about ‘CurveOnSurface’, it also can success to deal with it. I want to know how to achieve it. More thx if you can give me a advice.

Posts: 2

Participants: 1

Read full topic

Getting Numpy inside Rhino

$
0
0

@ivelin.peychev wrote:

Hi,

Just read this answer:

And decided to share my recent findings.

I decided to create a new thread as I think it deserves it, also that thread is pretty old.

Recently while I was experimenting mixing languages I read an article regarding ‘pythonnet’ and their new developments that allow to start CPython interpreter from a dotnet application.

There is a nuget package called: Python.Runtime.NETStandard.3.7.1

With it, you are able to run locally installed CPython with whatever modules you have installed there and pass inputs and outputs from IronPython to CPython and vice versa.

In my example I made a comparison using RTree and numpy’s algorithm to finding points within a sphere.

rtree_vs_numpy.gh (9.5 KB)

Of course the performance compared with RTree is bad, but I give it credit for giving the indecies of the points in order. :wink:

I believe this will allow lots of new algorithms and new approaches for old problems.

Enjoy :slight_smile:

IMPORTANT: You MUST use CPython3.7.x+ otherwise Rhino will crash. :stuck_out_tongue_winking_eye:

Posts: 1

Participants: 1

Read full topic

Viewing all 4120 articles
Browse latest View live