@JimCarruthers wrote:
Is there a method for doing a simple file export without using "Command"?
Thanks
Jim
Posts: 3
Participants: 3
@JimCarruthers wrote:
Is there a method for doing a simple file export without using "Command"?
Thanks
Jim
Posts: 3
Participants: 3
@dcantwell wrote:
In Rhino 5, I have manually created some GPS tracks of the Pacific Crest Trail using Halfmiles GPS data files (using a GPX converter from another website) and then manipulating the geometry to get reasonable elevation profiles superimposed on google maps. I like the results but I need some advice. Since I believe there are many GPS track files available for public use, I could envision virtual trips thru many offroad destinations. Think Google earth without the constant need to control the flight. Towards that end, can python be linked with other web tools to exchange data or files between the apps. I manually go to a website enter a filenames and parameters, execute a conversion, then download those files. In python I execute a XPS reader that generates a profile curve. I do the same for extracting a google map image for a pictureframe. Can I automate this ?
Posts: 1
Participants: 1
@Ncik wrote:
G'day Everyone,
Does anyone have a script for saving a file with date and/or time appended to the front? Similar to incremental save functionality it will create a new file each time and/or each day it is run.
regards,
Nick.
Posts: 1
Participants: 1
@JimCarruthers wrote:
Is it possible to add some custom text to the man Rhino window Title Bar?
Posts: 1
Participants: 1
@brobes05 wrote:
I am new to python (sort of), anyway I am not sure why this is not working. Should be simple to weave two lists together with a boolean pattern of true false.
I don't really understand how to flatten the two lists after using python's built in 'zip' function.
import rhinoscriptsyntax as rs list1 = [] list2 = [] list3 = [] for x in range (0,20,2): y = 0 z = 0 ptlist1 = rs.AddPoint(x,y,z) list1.append(ptlist1) for x2 in range (0,20,3): y = 0 z = 0 ptlist2 = rs.AddPoint(x2,y,z) ptlist2move = rs.MoveObjects(ptlist2, (0,5,0)) # rs.DeleteObjects(ptlist2) list2.append(ptlist2move) def weaveLists(): zip(list1, list2) flattenList = [item for sublist in zip(list1, list2) for item in sublist] #this line confuses me list3.append(flattenList) return rs.AddPolyline(list3) # attempting to weave lists together with a boolean pattern like the 'weave' pattern in # grasshopper.
Posts: 1
Participants: 1
@jospehkoon wrote:
I have recently been writing basic Python code for Rhino 5 Mac.
I have read through the primers, but still have a few questions.Currently, I am storing all of the code inside Rhinoceros > scripts > folder:
Where is the best place to store your Python scripts ?Currently, I execute all of the code with the RunPythonScript command and manually select the file :
What is the best way to execute code inside of Rhino 5 Mac ?Currently, I am editing all of the code inside Xcode (which doesn't provide debugging errors or shortcuts):
What is the best software to edit Rhino 5 Python code in ?Thanks
Posts: 2
Participants: 2
@juancarreras wrote:
Is there a way to extract the rotation angle of an object in relation to its original position when it was created ?
Ideally I'd like to be able to display an annotation tag that shows that angle, always in relation to its original angle (zero).
I need only its rotation on the xy plane.
How can this be scripted ?
Thanks
Posts: 11
Participants: 2
@elaner wrote:
I am trying to set the color of a cylinder I created using python. Cylinder is created, but the color does not change.
Here is the script. Any help is appreciated.
import Rhino import utility as rhutil import scriptcontext import System.Guid import re import math import time import sys import System.Windows.Forms.DialogResult import System.IO.File import object as rhobject from scriptcontext import doc import Rhino.UI import rhinoscriptsyntax import System.Drawing.Color import System.Enum import System.Array import System.Windows.Forms from view import __viewhelper import os def AddCylinder(base, height, radius, cap=True): """ Adds a cylinder-shaped polysurface to the document Parameters: base = The 3D base point of the cylinder or the base plane of the cylinder height = if base is a point, then height is a 3D height point of the cylinder. The height point defines the height and direction of the cylinder. If base is a plane, then height is the numeric height value of the cylinder radius = radius of the cylinder cap[opt] = cap the cylinder Returns: identifier of new object if successful None on error """ cylinder=None height_point = rhutil.coerce3dpoint(height) if( height_point!=None ): #base must be a point base = rhutil.coerce3dpoint(base) if( base!=None ): normal = height_point-base plane = Rhino.Geometry.Plane(base, normal) height = normal.Length circle = Rhino.Geometry.Circle(plane, radius) cylinder = Rhino.Geometry.Cylinder(circle, height) else: #base must be a plane base = rhutil.coerceplane(base) if( base!=None ): circle = Rhino.Geometry.Circle(base, radius) cylinder = Rhino.Geometry.Cylinder(circle, height) if( cylinder==None ): return scriptcontext.errorhandler() brep = cylinder.ToBrep(cap, cap) id = scriptcontext.doc.Objects.AddBrep(brep) if( id==System.Guid.Empty ): return scriptcontext.errorhandler() return id """ scriptcontext.doc.Views.Redraw() """ x = 20. y = 30. thickness = .5 radius = .5 base = Rhino.Geometry.Point3d(x, y, thickness) top = Rhino.Geometry.Point3d(x, y, thickness+.1) scyl = AddCylinder(base, top, radius) rhinoscriptsyntax.ObjectColor(scyl,(25,50,255))
Posts: 5
Participants: 2
@Helvetosaur wrote:
Continuing the discussion from Toggle toolbar visibility without knowing its parent "collection":
Running the following script in my setup errors out on the line indicated:
import rhinoscriptsyntax as rs def ToggleToolbarVisibility(tb_name): for tb_coll in rs.ToolbarCollectionNames(): if rs.IsToolbar(tb_coll,tb_name): #<--Here if rs.IsToolbarVisible(tb_coll,tb_name): rs.HideToolbar(tb_coll,tb_name) else: rs.ShowToolbar(tb_coll,tb_name) break ToggleToolbarVisibility("ToolbarName")
The error message is: "expected int, got str"
IsToolbar () is expecting an index for tb_name and not a string.
Edit - Never mind... apparently the example I am using needs the third argument in IsToolbar() to be True. Otherwise, with the default=False it errors out. Still, somehow this should be error tolerant and return None, not blow up... No?
--Mitch
Posts: 1
Participants: 1
@JimCarruthers wrote:
Hi group,
I'm trying to read some form information from PDF files. I'm trying to connect to Acrobat from Python in Rhino, and looking at every example I can Google I seem to be missing something. I'm successfully able to connect to Acrobat Pro XI and open the file and get a reference to it--confirmed by trying out grabbing some basic properties--but long story short I can't figure out how to correctly use the getField method to get a reference to a form field, I can't find the right context in which to call it, neither on the "app" nor the "document" nor the "Javascript object" works. It seems like (if you look up this stuff) the "GetJSObject" step isn't working, it doesn't crash but anything I attempt to call on the object(whether a valid procedure or not) returns the baffling error "Value does not fall within the expected range"
Here's a sample code:
from System import Type, Activator
def main():
TestFile="your-pdf.pdf"
AVDoc=Activator.CreateInstance(Type.GetTypeFromProgID("AcroExch.AVDoc"))
AVDoc.Open(TestFile,"")
ppdoc=AVDoc.GetPDDoc()
jso=ppdoc.GetJSObject()
print jso.getField('ReferenceID').value()if name=="main":
main()Thanks,
Jim
Posts: 1
Participants: 1
@Steven_Elliott wrote:
I'm trying to compile my python script into a plugin for Rhino 5 but am running into an issue that I am not able to fix. When I run my script in the Rhino editor it runs fine, although when compiled into a plugin (Im using the Rhinoscript Compiler) the script will not run all the way through. It's really tough to debug when I cannot see an error like when I do in the editor.
I've tried putting print commands in the script to see exactly when it is failing and ive sort of narrowed it down to a line or to but still cannot see when the issue is when the script is running just fine in the editor. Here is a snip of the code where I think I am running into the error:
def BuildComponent(MPoints,EPoints,Degree,Components): if Components == 1: Curves = [] for CrossSection in range(len(MPoints)): Curves.append(RS.AddCurve(MPoints[CrossSection])) elif Components == 2: Curves = [] for Count in [0,1]: for CrossSection in range(len(MPoints[Count])): Curves.append(RS.AddCurve(MPoints[Count][CrossSection])) Sections = [RS.AddLoftSrf(Curves,None,None,Degree)]
If there was some way to see the errors python is returning in the rhino command window it would help a lot but I'm sure that there is.
I appreciate any help
Posts: 1
Participants: 1
@Maarten wrote:
We are scripting the Heigthmap command in Python scripting. A popup with a warning become visible.
Is it possible to get rid of this popup?
Posts: 1
Participants: 1
@Frederic_Trastour wrote:
Hi all,
in a VB script, I do a batch export into OBJ format.
For each created file I get an error dialog box warning about too long material names, but output OBJ files are ok.I'm wondering if there is a way to get rid of this dialog box ?
Best regards,
Frédéric.
Posts: 1
Participants: 1
@DanBayn wrote:
Sorry, I should have put more thought into this before asking for help.
The LayerChildren method is what I was overlooking.
Dan
Posts: 1
Participants: 1
@benjamin wrote:
My current method for quickly selecting all the instances of a selected block is by bringing up the block manager and then hitting the select button.
Is there a method that could be written which does this quicker? Bringing up the block manager is quite time consuming once the model builds up.
Of course there is SelBlockInstanceNamed but scrolling through the names to remember which one you want is also not ideal.
So the logic would be something like: (Prompt user to select block) ▶ Select all items with reference block ID ▶ return selected Blocks
Would also be good if it could work with multiple selections of block instances
Any ideas?
Cheers
Posts: 3
Participants: 2
@Keith1634 wrote:
Hi,
I am reading a text file to feed a Rhino.ListBox - however I always get a UTF8_BOM (  ) mark on the first line. Is there a way to remove this ?
thanks,
Keith
Posts: 3
Participants: 2
@Willem wrote:
Hi,
Is there a way to have RemoveMultiKnot functionality from within RhinoCommon?
Thanks
-Willem
Posts: 3
Participants: 3
@Jarek wrote:
Hi Group,
Is there a way to easily represent a combination of flags (for example for object types in ObjectsByType method) into a single hexadecimal value that can be provided into the method?
For example, I want 4+8+16 - can I instead provide a single &H... value for that combo?--jarek
Posts: 7
Participants: 3
@daizhuo wrote:
Hi!
Although I finally found that someone said "grayscale = RGB.R*0.3+RGB.G*0.59+RGB.B*0.11", but it seems not work. I had tomultiply 0.007 and got a result that seems grayscale was form 0 to 1. Here is my code:import rhinoscriptsyntax as rs import math import System as sys import Rhino.Geometry as rg import scriptcontext as sc path = path bitmap = sys.Drawing.Bitmap.FromFile(path) width = bitmap.Width height = bitmap.Height unum = 20 vnum = 20 uinc = 1.0/unum vinc = 1.0/vnum imageW=width/unum imageH=height/vnum panels=[] temp=[] for i in range(unum): for j in range(vnum): valRGB = sys.Drawing.Bitmap.GetPixel(bitmap,i*imageW,j*imageH) _**val = (valRGB.R*0.3+valRGB.G*0.59+valRGB.B*0.11)*0.007**_ pt1 = srf.PointAt(i*uinc,j*vinc) pt2 = srf.PointAt((i+1)*uinc,j*vinc) pt3 = srf.PointAt(i*uinc,(j+1-val)*vinc) pt4 = srf.PointAt((i+1)*uinc,(j+1-val)*vinc) panel = rg.NurbsSurface.CreateFromCorners(pt1,pt2,pt4,pt3) panel2= rg.NurbsSurface.CreateFromCorners(pt1,pt2,pt4,pt3) center = srf.PointAt((i+0.5)*uinc, (j+0.5)*vinc) normal = srf.NormalAt((i+0.5)*uinc, (j+0.5)*vinc) panel = rs.RotateObject(sc.doc.Objects.AddSurface(panel),center,val*math.pi*4,normal) panels.append(panel) a = panels
Posts: 3
Participants: 2
@Alexander_Kaplan wrote:
I'm using a slightly modified version of http://wiki.mcneel.com/developer/scriptsamples/exportlayerobjects for a mass fbx export but have to hold down enter for a minute while it exports. Silly. Is there a reason the "-" flag on Export wouldn't work?
Snippet with the rhino command
If IsArray(arrSelected) Then ' Generate a modified path string ' that includes the layer name strFile = strPath strFile = Replace(strFile, ".3dm", "_" & strLayer & ".fbx") ' strFile = strLayer & ".fbx" ' Export the selected objects Rhino.Command "_-Export " & strFile, 0 End If Next
Posts: 7
Participants: 2