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

Can patch mesh be created with Rhino Common?

$
0
0

@Terry_Chappell wrote:

Currently I use:

rs.Command(‘NoEcho -MeshPatch EnterEnd’)

to create a patch mesh from selected points. Is there a way to do this using Rhino Common calls that do not require that I add visible points to the document, that is , that use only the geometry of the points to create the patch mesh?

Regards,
Terry.

Posts: 10

Participants: 4

Read full topic


Vbscript curve class

$
0
0

@cshea wrote:

vbscript:
I would like to make a make a copy of a curve (basecurve) and perform transform methods to this copy (newCurve) without changing the original basecurve.
because curve is a class, any changes i make to the newCurve changes the baseCurve which is not what I want.
how can I overcome this?

Posts: 2

Participants: 2

Read full topic

Connect Curves

$
0
0

@Alasdair wrote:

Is there a something similar to the “Connect” function in Rhino python? I tried adding a 0mm fillet but I realised that won’t work using python.

Cheers

Posts: 1

Participants: 1

Read full topic

Script Planar Quad Mesh

$
0
0

@Antonio_Cersosimo wrote:

Hi, does anyone knows if there is a quick method in rhinoscriptsyntax or in Rhino for generating a planar quad mesh, define with boundary and subdivision in X,Y. Thanks

Posts: 3

Participants: 2

Read full topic

Page number by rs.TextObjectText

$
0
0

@bojdol wrote:

I am trying to use rs.TextObjectTextfunction and it works well, but when i am putting %% into text to achieve page number it is not changed into proper number, but displayed(and printed) as “%%” until I double-click on it and deactivate it. is it common issue? Is any smart way of dealing with it?

Posts: 6

Participants: 3

Read full topic

AddSweep1 Function, Incorrect Output - Need help debugging

$
0
0

@ebe.farooqui wrote:

Hey everyone!

I’m attempting to use the addsweep1 function to take a circle object and sweep it around a given figure. See the picture below

46%20PM

The expected output should look something like:

57%20PM

However, when I run the addsweep1 command from my script, I get the following:

57%20PM

Here’s a snippet of the addsweep1 code I’m running:

rs.AddSweep1(figure_curve, [circle])

Any insights?

Posts: 10

Participants: 3

Read full topic

Create 3D-printable Object With No Capped Sides

$
0
0

@ebe.farooqui wrote:

I have a “frame,” and a tab it’s standing on, as seen below that I’d like to make available to 3D print. I would only like the frames of the figure and box to be 3d printed and not the entire object as a solid.

04%20AM

Currently, I’m using the AddPipe command to create a surface so that the frame looks like:

37%20AM

However, when I try to export it as an .stl file, I get the following error message:

“No surface objects to export”

Could anyone give any insight on this matter?

Posts: 1

Participants: 1

Read full topic

Development one script


Reference RhinoPython selected object in IronPython

$
0
0

@onrender wrote:

Hi there,

I was thinking what if I selected an object by an RhinoPython method and I want to link that object in IronPython in the same code?

Posts: 3

Participants: 2

Read full topic

Help diagnosing a simple python script

$
0
0

@declan wrote:

Hi all,

I’m trying to create a simple python script to loop through a selection of crvs and check for minimum clearance between them. Basically simulating the CrvDeviation tool, but running it between all curves at once.

Could anyone take a look at the attached and help me understand where I’m going wrong?

tx!

Declan

CrvDevTest.3dm (37.5 KB)
CrvDevTest.py (636 Bytes)

Posts: 4

Participants: 2

Read full topic

Python / RhinoCommon deprication messages

$
0
0

@clement wrote:

Hi @piac,

are deprication messages still enabled in RH6 (6.5.18111.2181, 21.04.2018) ?

I did not see any come up after testing 30 scripts to be ported for V6. The most i got from:

scriptcontext.doc.Layers.FindByFullPath(str_path, ignoreDeletedLayers)

It looks like the ignoreDeletedLayers option has been added so it accepts a boolean value instead of -1 as it’s been in V5. Just want to make sure i am not missing something.
_
c.

Posts: 1

Participants: 1

Read full topic

Custom File import/export

$
0
0

@jj1 wrote:

Hi Guys,
I have a Question, does anybody ever make a custom 3dm Import export for another cad Software to be able to import Rhino Files natively?
Is this possible at all?

Posts: 2

Participants: 2

Read full topic

Data history

$
0
0

@BaptisteCo wrote:

Hi,
I have many backup files that I saved almost every day for a year. I recorded a lot of data as UserTexts on geometries. I’d like to build a script that could read every file and access UserTexts to see if and when it has been changed.
Is there a way to loop on the rhino files of a windows directory using python and then read UserTexts and store them in a variable?
Did anybody try to do something similar ?
Thanks

Posts: 3

Participants: 2

Read full topic

Help with scripting

$
0
0

@mohamedalboush wrote:

Hello everyone,
I’m new to scripting through Python, but for a first try I think I’m doing a progress…hopefully!!
I’m trying to create a spiral staircase, and it’s almost done. I’m having a problem creating a loop for the posts on the rails (which appear as lines in the photo) and creating surfaces for the steps.

Could anyone help?!

(the problem is in the end of the file)

Spiral Staircase.py (4.1 KB)

UPDATE:
I managed to create the steps with (NurbsSurface.CreateFromCorners)
The remaining problem is the posts on the rails, and here is the coding the I wrote for it:
posts = [ ]
for i in range(0, 49):
posts.append(rs.AddPipe(lineStepList5[i], rs.CurveDomain(lineStepList5[stepsCount-1])[0], radius2/3))

which only works if I applied it to one line like this:
posts = rs.AddPipe(lineStepList5[49], rs.CurveDomain(lineStepList5[stepsCount-1])[0], radius2/3)

Posts: 1

Participants: 1

Read full topic

Select every objects in a script

$
0
0

@amineboussoualim wrote:

Hi, i want to know how to select every object with rhinoscript, like doing a Ctrl + A, i tried this whitout succes :

Dim arrObjects
arrObjects = Rhino.AllObjects
Rhino.SelectObjects arrObjects

Posts: 4

Participants: 3

Read full topic


Triangulation patterns in .ifc file format using coordinates and indexes

$
0
0

@yafimski wrote:

I’ve posted this in another forum as well due to the mathematical nature of the issue: forum post

I’m doing some manipulation of raw string data from an .ifc file exported from Archicad. I thought that this problem might be addressed also here.
I have an .ifc file in which the raw data exported describes a wall in the xy plane by a set of coordinates and their corresponding indexes according to the link explanation:

Explanation

Attached is a txt file where the data is divided into the coordinates in xyz space, then indexes and some other data.
coordinates.txt (17.5 KB)

I was hoping that someone can help me understand how to link the indexes to their corresponding coordinates. There are 164 coordinate pairs and 324 index pairs so it doesn’t make sense to me that each index relates to only 1 coordinate pair.

The goal is to establish a relationship between indexes and coordinates such that this type of data can output the wall thickness, which is in this case ‘10’. I was thinking that (according to the link above) by taking the first triangle described, it should describe the edge of the wall in 3D and therefore give us one of its sides as the shortest segment in the wall which is the thickness.

I received an answer in the mentioned forum post, that I should "…expanding out each coordinate in terms of X’s, Y’s, and Z’s [instead of (X,Y,Z) triples) and then use every index triple to get the actual coordinate for the individual coordinate instead of one triple. So for example you have X[], Y[] and Z[] and you have an index (a,b,c) then you find X[a], Y[b], and Z[c] not Point(a,b,c)… "

I didn’t quite understand this explanation, and would appreciate any help or further explanation in order to achieve my goal, especially linking the indexes to actual coordinate xyz points.

Thank you

Posts: 1

Participants: 1

Read full topic

Script to array objects with Packing Algorithm

Python script, help me understanding this

$
0
0

@maxz wrote:

I haven written a python script to create a testtrack purposed to test the cornering behaviour of a cad/cam machine. The script creates a polyline with incremental corner sharpness every time it has come full circle.
Every time the corner changes sharpness, it prints the new corner together with the distance travelled. As a backup, it creates or updates a text file with the same values.
The script works fine, the polyline and the printed values appear almost instantaneously in Rhino when the script is started. The problem is, it continues to do something for the next minute or so. It gets there in the end, but I am puzzled as to what causes the delay. I tried commenting out the lines related to the text file, but nothing changed.

Can someone shed some light on this?

The script:
# Testtrack for CAM angle negotiation.
# by Max Zuijdendorp, April 2018

# dit script creeert een polyline van een track met bochten (richtingsveranderingen) die in scherpte toenemen tot 180 graden, waarmee je het bochtgedrag van de freesmachine kunt testen.
# de bocht wordt met dezelfde scherpte herhaald totdat een volledige cirkel is doorlopen.
# in regels 19 t/m 22 worden de starthoek van de eerste bocht, de toename van de bochthoek na elke cirkel, de lengte van elk lijnstuk en de hoek van de laatste bocht die nog meegenomen wordt vastgelegd.
# als je in regel 19 de waarde van een "verdachte" hoek invult, en in regel 20 de waarde 0 invult kun je een volledige cirkel met die hoek doorlopen om de machine te testen.

import rhinoscriptsyntax as rs
import math

# Check of laag "Testtrack" bestaat, indien niet voeg deze laag dan toe
if not rs.IsLayer("Testtrack"):
	rs.AddLayer("Testtrack")
	
rs.CurrentLayer(layer="Testtrack")

def DRAWTRACK():

	corner =4			# hoek in graden van de eerste bocht (niet op 0 zetten)
	cornerincr = 0.5 	# hoek in graden waarmee de bocht toeneemt bij elke nieuwe cirkel. Indien dit 0 is wordt maar 1 cirkel getekend
	sectionlen = 10 	# lengte van de lijnstukken
	lastcorner = 180 	# scherpste hoek die nog meegenomen wordt.
	
	angle = 0	
	repeat = 0		
	start = (0,0,0)	
	run = True
	totallen = 0
	Pointlist = []
	Pointlist.append (start)
	
	diamax = sectionlen/math.sin(corner*math.pi/360)
	if (diamax > 500):  # diameter van de eerste/grootste cirkel
		print"Maximum machinebereik overschreden"
		run = False
	
	if run:
		createtextfile = True	# True maakt tekstbestand aan of ververst het, False niet.
	
		if createtextfile:
			f=open("//Users/maxzuijdendorp/Desktop/Hoeken.txt",'w')
			f.write("Eerste bochthoek:  "+str(corner)+'\n')
			f.write("Laatste bochthoek:  "+str(lastcorner)+'\n')
			f.write("Hoektoename:  "+str(cornerincr)+'\n')
			f.write("Lengte lijnsegment:  "+str(sectionlen)+'\n')	
			f.write('\n')
			f.write("Snijlengte-Nieuwe Hoek\n")
	
		imax = 1	# als cornerincr 0 is wordt maar 1 keer een cirkel doorlopen, in alle andere gevallen wordt hieronder het aantal cirkels berekend.
		if (cornerincr <> 0):
			imax = int((lastcorner-corner)/cornerincr)+1

	
		for i in range(0,imax,1):
			repeat = int(360/corner)+1 # de bocht wordt herhaald met dezelfde hoek totdat tenminste 360 graden doorlopen is
			for n in range(0,repeat,1):
				angle = angle + corner
				point = rs.Polar(start, angle, sectionlen, rs.WorldXYPlane() ) #	WorldZXPlane	WorldYZPlane
				end = point

				Pointlist.append (point)
				start = end

			corner = corner + cornerincr
			totallen = totallen+(n+1)*sectionlen
			print totallen, corner
		
			if createtextfile: f.write(str(totallen)+"    "+str(corner)+'\n')
		
		rs.AddPolyline (Pointlist)
		if createtextfile: f.close()
		


DRAWTRACK()

Posts: 1

Participants: 1

Read full topic

Web-Crawler for "Food4rhino"

$
0
0

@valmirkastrati wrote:

Hey guys.

I was trying to create a list of all the add-on apps that exist for grasshopper in food4rhino, and since I’ve been doing some python coding lately (by creating simple things directly in Grasshopper) I thought, I might as well just write a short code, “a webcrawler” in pycharm to get the information all at once, and not manually 1 by 1.

I was looking to get, Title, Description and Link.

I was looking at this tutorial how to write a spider/webcrawler but something seems to not work, and I literally have no Idea what.

here is the code, if someone can help, thanks a lot.

import requests
from bs4 import BeautifulSoup

def addons_spider(max_pages):
page = 0
while page <= max_pages:
url = “http://www.food4rhino.com/browse?searchText=&page=0%2C” + str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for link in soup.findAll(‘a’, {‘class’: ‘f4r_list_content_title’}):
href = link.get(‘href’)
print(href)
page += 1

addons_spider(5)

Posts: 1

Participants: 1

Read full topic

Iron Python read/write data to Microsoft Word (*.doc) files?

$
0
0

@agi.andre wrote:

I’m trying to create/populate a Word document .docx file with data from grasshopper.
Do anyone know how this can be done?

What I’ve found is this code for ironpython: https://gist.github.com/ejstembler/1049552

`import sys
import clr
import System
from System import DateTime

clr.AddReference(“Microsoft.Office.Interop.Word”)
import Microsoft.Office.Interop.Word as Word

def doc_replace_text(source_filename, tokens, values, destination_filename):

missing = System.Type.Missing
replaceAll = Word.WdReplace.wdReplaceAll

word_application = Word.ApplicationClass()
word_application.visible = False

document = word_application.Documents.Open(source_filename)

for i in range(len(tokens)):
    for r in document.StoryRanges:
        #print "i = %d, tokens[i] = %s, values[i] = %s" % (i, tokens[i], values[i])
        r.Find.Text = tokens[i]
        r.Find.Replacement.Text = values[i]
        r.Find.Wrap = Word.WdFindWrap.wdFindContinue
        r.Find.Execute(missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, replaceAll, missing, missing, missing, missing)

document.SaveAs(destination_filename)
document.Close()
document = None

word_application.Quit()
word_application = None`

But when trying to load the template document into the grasshopper python editor I’m getting a None return. Anyone who can spot the problem? Or won’t this simply work in grasshopper?
Thanks!

Posts: 1

Participants: 1

Read full topic

Viewing all 5806 articles
Browse latest View live