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

Adjust DWG-import-Script from V6 to V7

$
0
0

Hello, unfortunately our script no longer works.

The following line causes problems
Dim strFile : strFile = Rhino.OpenFileName(“Wähle DWG”, “DWG Files (.dwg)|.dwg||”, “dwg”)
Dim strCmd : strCmd = "_-Insert _File=Yes " & Chr(34) & strFile & Chr(34) & " " & “_ENTER _ENTER 0,0,0 _ENTER _ENTER”
Rhino.Command strCmd

The command to insert the File has changed in Rhino7 i think but i can’t get it to work.

Please help
Thanks in Advance
Regards

3 posts - 2 participants

Read full topic


Brep.Split() with curves - why is the first element in the return list always None?

$
0
0

As an example, let’s say you have a single surface and two closed curves that lie on it.
Selecting the surface and the curves, coerce them to a brep and a list of curve objects, then run:

splits=brep.Split.Overloads[IEnumerable[Rhino.Geometry.Curve],System.Double](crvs, tol)

The return always looks like this:
image

Why is the first element None? I would have thought it might return True if the split was successful…

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_Split_3.htm

Is it because one of the 5 overloads on this method has an out parameter so they all have to have a reserved first index even if there’s nothing to return on the other 4 overloads?

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_Split_1.htm

Or something else?

3 posts - 2 participants

Read full topic

Custom Boolean Difference

$
0
0

Dear Altruists,
I would like to create custom boolean difference between two/ multiple objects.

I have two objects like the right model in the attached picture. Now I would like to create a hollow in the green object with the second orange object. I can use the “boolean difference” for the job but it only creates the hollow of the same size of orange object. I would like to create a hollow in the intersection place of green and orange with custom shape like the left model in the attached picture.

I was actually looking for a python script that will help me save time for multiple objects.

2 posts - 2 participants

Read full topic

About RunScript question

$
0
0

Hi everyone, I’m writing a RhinoCommon by C#. I want to run two rhino’s command in my program then I use Rhino.RhinoApp.RunScript("_SelAll _cap", true), but it does not work. Could someone help me how can write the correct Script for this?
Thanks for the help!

4 posts - 3 participants

Read full topic

How to add ezdxf module to Rhino python?

$
0
0

I tried to add c:\Python38 path to Rhino python options, but still didn’t find the module “Message: No module named ezdxf”

ezdxf source: ezdxf · PyPI

2 posts - 2 participants

Read full topic

Python Hatch pattern on multiple objects

$
0
0

Hi! I’m very new to python and running into a probably simple error if anyone could help. I’m trying to make a script to duplicate a hatch and assign layers and a new hatch pattern for the duplicate. I’ve got the below worked out and it works great for a single hatch (ie I only hatch one square) For some reason if I hatch multiple objects the last command rs.hatchpattern does not work, everything else functions but the hatchpattern does not seem to run on multiple inputs.

Thanks! I’m probably missing something simple…

import rhinoscriptsyntax as rs
rs.Command("_hatch")
hatches = rs.LastCreatedObjects()
if hatches:
rs.ObjectLayer(hatches, “NC_DRAFTING::HATCH::Hatch”)
rs.CopyObject(hatches)
poche = rs.LastCreatedObjects()
rs.ObjectLayer(hatches, “NC_DRAFTING::HATCH::Poche-Light”)
rs.HatchPattern(poche, “Solid”)

this is the error I get:

Message: Parameter must be a Guid or string representing a Guid

Traceback:
line 890, in coerceguid, “C:\Users\Nick_Work\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py”
line 1062, in coercerhinoobject, “C:\Users\Nick_Work\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py”
line 237, in HatchPattern, “C:\Users\Nick_Work\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\hatch.py”
line 12, in , “C:\Users\Nick_Work\AppData\Local\Temp\TempScript.py”

5 posts - 2 participants

Read full topic

MeshClosestPoint - Minimal 3d shape with tolerance - Virtual point cloud of 3d shape

$
0
0

Hi,
Has anyone studied the possibility to produce more detailed simple model than BoundingBox or MinimalBoundingBox? I wonder if there’s a way to find the closest points in 3d point array with parametric tolerance / point distance to find outer limits of simplified 3d shape?

If you use ReduceMesh, then it will ultimately lose some of the polygon connections and alter the outer limits of the original 3d shape. This idea would be 3D point array bounding shape type of solution without losing the original outer limits.

I think the point array for the 3d coordinates will not be an issue, but how to draw that shape in 3d? It’s basically a virtual point cloud of the original shape :slight_smile: So, any suggestions and ideas? Or hint if there’s a ready solution already to be found?

11 posts - 2 participants

Read full topic

One extrude command for extruding curves and surfaces

$
0
0

Hello there !

I would like to ask if is possible to make script, that will decide what command will be used if is selected curve or surface. Simply merge the 2 existing commands: ExtrudeCrv and ExtrudeSrf to one, based on selection. I have done something, but it not working as I expected, I´m totally newbie in scripting.

Dim strObject

strObject = Rhino.GetObject(“Select a curve”)

If Rhino.IsCurve(strObject)Then

Rhino.Command "_SelPrev"
Rhino.Command "_ExtrudeCrv"

Else

Rhino.Command "_SelPrev"
Rhino.Command "_ExtrudeSrf"

End If

It will be very helpfull instead of using 2 commands, it will make Rhino more user friendly :slight_smile:

Thank for help
Tom

10 posts - 3 participants

Read full topic


Change cell color gridview

$
0
0

Hello guys , i have a gridview with 4 columns , what i want is to color just column named Color , i finded a code but color every single cell of the row and i don’t want this. The code it’s attached below photo!
image ,

import rhinoscriptsyntax as rs
import scriptcontext as sc
import System
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms
import sqlite3

class PLATE(forms.Dialog):
    # Initializer
    def __init__(self):
        self.Size = drawing.Size(380,200)
        self.mainlay = forms.PixelLayout()
        
        self.stock_grid = forms.GridView()
        self.stock_grid.ShowHeader = True
        column1 = forms.GridColumn()
        column1.HeaderText = 'Stock'
        column1.Width = 110
        column1.Editable = False
        column1.DataCell = forms.TextBoxCell(0)
        self.stock_grid.Columns.Add(column1)

        column2 = forms.GridColumn()
        column2.HeaderText = 'Thickness'
        column2.Editable = False
        column2.DataCell = forms.TextBoxCell(1)
        self.stock_grid.Columns.Add(column2)

        column3 = forms.GridColumn()
        column3.HeaderText = 'Material'
        column3.Editable = False
        column3.Width = 110
        column3.DataCell = forms.TextBoxCell(2)
        self.stock_grid.Columns.Add(column3)

        column4 = forms.GridColumn()
        column4.HeaderText = 'Color'
        column4.Editable = False
        column4.Width = 60
        column4.DataCell = forms.TextBoxCell(3)
        self.stock_grid.Columns.Add(column4)
        self.mainlay.Add(self.stock_grid,0,0)
        self.Content = self.mainlay
        self.stock_grid.DataStore = [['PL AL-H111 T1', '1.0', 'Aluminium H111', '66'], ['PL AL-H111 T2', '2.0', 'Aluminium H111', '95'], ['PL AL-H111 T3', '3.0', 'Aluminium H111', '93'], ['PL AL-H111 T4', '4.0', 'Aluminium H111', '141'], ['PL AL-H111 T5', '5.0', 'Aluminium H111', '155'], ['PL AL-H111 T6', '6.0', 'Aluminium H111', '203'], ['PL AL-H111 T7', '7.0', 'Aluminium H111', '8'], ['PL AL-H111 T8', '8.0', 'Aluminium H111', '215'], ['PL AL-H111 T9', '9.0', 'Aluminium H111', '57'], ['PL AL-H111 T10', '10.0', 'Aluminium H111', '241'], ['PL AL-H111 T11', '11.0', 'Aluminium H111', '199'], ['PL AL-H111 T12', '12.0', 'Aluminium H111', '133'], ['PL AL-H111 T13', '13.0', 'Aluminium H111', '13'], ['PL AL-H111 T14', '14.0', 'Aluminium H111', '44'], ['PL AL-H111 T15', '15.0', 'Aluminium H111', '167']]
        self.DictStocks = [{'SIND': '66', 'SNAME': 'PL AL-H111 T1', 'SRGB': '(95,127,0)', 'SMAT': 'Aluminium H111', 'ID': 1, 'ST': '1.0'}, {'SIND': '95', 'SNAME': 'PL AL-H111 T2', 'SRGB': '(76,153,76)', 'SMAT': 'Aluminium H111', 'ID': 2, 'ST': '2.0'}, {'SIND': '93', 'SNAME': 'PL AL-H111 T3', 'SRGB': '(102,204,102)', 'SMAT': 'Aluminium H111', 'ID': 3, 'ST': '3.0'}, {'SIND': '141', 'SNAME': 'PL AL-H111 T4', 'SRGB': '(127,223,255)', 'SMAT': 'Aluminium H111', 'ID': 4, 'ST': '4.0'}, {'SIND': '155', 'SNAME': 'PL AL-H111 T5', 'SRGB': '(76,114,153)', 'SMAT': 'Aluminium H111', 'ID': 5, 'ST': '5.0'}, {'SIND': '203', 'SNAME': 'PL AL-H111 T6', 'SRGB': '(178,102,204)', 'SMAT': 'Aluminium H111', 'ID': 6, 'ST': '6.0'}, {'SIND': '8', 'SNAME': 'PL AL-H111 T7', 'SRGB': '(128,128,128)', 'SMAT': 'Aluminium H111', 'ID': 7, 'ST': '7.0'}, {'SIND': '215', 'SNAME': 'PL AL-H111 T8', 'SRGB': '(153,76,153)', 'SMAT': 'Aluminium H111', 'ID': 8, 'ST': '8.0'}, {'SIND': '57', 'SNAME': 'PL AL-H111 T9', 'SRGB': '(127,127,63)', 'SMAT': 'Aluminium H111', 'ID': 9, 'ST': '9.0'}, {'SIND': '241', 'SNAME': 'PL AL-H111 T10', 'SRGB': '(255,127,159)', 'SMAT': 'Aluminium H111', 'ID': 10, 'ST': '10.0'}, {'SIND': '199', 'SNAME': 'PL AL-H111 T11', 'SRGB': '(57,38,76)', 'SMAT': 'Aluminium H111', 'ID': 11, 'ST': '11.0'}, {'SIND': '133', 'SNAME': 'PL AL-H111 T12', 'SRGB': '(102,204,204)', 'SMAT': 'Aluminium H111', 'ID': 12, 'ST': '12.0'}, {'SIND': '13', 'SNAME': 'PL AL-H111 T13', 'SRGB': '(204,102,102)', 'SMAT': 'Aluminium H111', 'ID': 13, 'ST': '13.0'}, {'SIND': '44', 'SNAME': 'PL AL-H111 T14', 'SRGB': '(153,114,0)', 'SMAT': 'Aluminium H111', 'ID': 14, 'ST': '14.0'}, {'SIND': '167', 'SNAME': 'PL AL-H111 T15', 'SRGB': '(63,79,127)', 'SMAT': 'Aluminium H111', 'ID': 15, 'ST': '15.0'}]
        self.stock_grid.CellFormatting += self.OnCellFormatting
    
    def SearchInDict(self,index):
        to_return = None
        if self.DictStocks:
            for stock in self.DictStocks:
                if stock["SIND"] == index:
                    to_return = stock["SRGB"]
                    break
        return to_return
    def OnCellFormatting(self, sender, e):
        try:
            target = self.stock_grid.DataStore[e.Row][3]
            color = eval(self.SearchInDict(target))
            color = drawing.Color.FromArgb(color[0],color[1],color[2])
            e.BackgroundColor = color
        except Exception as e:
            print e
dialog = PLATE()
dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)

3 posts - 2 participants

Read full topic

How to import and assign rmtl to object

$
0
0

Hi all. Rhino 7 . I would like to use my rmtl files. How to import and assign to object with common c# ?
I tried with :
Rhino.DocObjects.Material myMaterial = new
Rhino.DocObjects.Material(Rhino.DocObjects.Material.DefaultMaterial);
myMaterial .Reflectivity = Reflectivity;
myMaterial .Shine = Shine;
myMaterial .Name = Name;
var texture = new Rhino.DocObjects.Texture();
texture.FileName = FileName;
texture.TextureType = Rhino.DocObjects.TextureType.Bitmap;
texture.Enabled = true;
myMaterial.SetBumpTexture(texture);
myMaterial.SetTexture(texture,Rhino.DocObjects.TextureType.Bitmap);
myMaterial.SetEnvironmentTexture(texture);
myMaterial.CommitChanges();
var index= Rhino.RhinoDoc.ActiveDoc.Materials.Add(myMaterial);
attribute.MaterialIndex = index;

I saw that some methods are deprecated but he first issue is that i cannot set the file for environement ( It is ok for color and bump)

3 posts - 2 participants

Read full topic

Looking for a script to enlarge polysurfaces in X and Y directions only....?

$
0
0

I have an exterior stone panel project that I have to change the joints size from 1/2" down to 1/4". All the stone is 1 1/4" thick and that needs to remain the same. So a simple offsetsrf command will not work, I only need the 1 1/4" edges moved/stretched 1/8" each way. Some of these panels are perpendicular to the cplane and some are not. It would be nice to have the resulting pieces copied to a new layer. I have attached a simple model with a few pieces. (R6 but I have R7 as well)

I’m willing to pay for the right script.

Thank You
Brian Wheeler
Crystal Marble Co.Script-example-enlarge stone-R6.3dm (2.8 MB)

2 posts - 1 participant

Read full topic

rs.GetObject - limit to selecting within a specific collection of objects?

Converting lines?

$
0
0

Hello.
I wonder. Is there a script similar to _SetLinetype. Create dashed lines with Polycurve objects

The input value is:

  • length of line
  • distance between lines

8 posts - 2 participants

Read full topic

Newbie trying to multiply vectors and matrices in Rhino script with python

$
0
0

I’ve been using Rhino for a couple of years but I’m just now learning to use scripts and I’m relatively new to Python as well. I’ve done some programs in Python using matrices and vectors with the module numpy. Rhino doesn’t seem to recognize numpy. Is there a way to add it or is there a Rhino way to deal with doing math on Python lists used as vectors?

4 posts - 3 participants

Read full topic

What is GetSet?


Ring with python

$
0
0

Hello,

I am a beginner to python.

Can anybody explain to me what went wrong here?

I wanted to get a ring with 3-point arcs at every side of the profile.

scripting looks good for me, but not the surface of the ring. The outside surface is strange. The other 3 are good working.

why not the outside?

thx for help.

3 posts - 2 participants

Read full topic

End MS Excel process with python script

$
0
0

Hello,

From my python script I can read/write Excel files without a problem

However, I can not completely “kill” Excel process from the script once I’m done with it…

There is an old thread on the forum about it but with no final solution.
Actually there are some guidelines which I do not understand…
( in the last post of the thread are mentioned “two dots” )

[Close an Excel session with Python]

I did not want to resurrect this old thread but I still need a solution

BR
Aleksandar

6 posts - 3 participants

Read full topic

Rhino.Geometry.Intersect.Intersection.MeshLine broken

$
0
0

Hi,

it appears to me that the latest Rhino7 update breaks the said function from the Rhino-Common API. I’ve got a couple of scripts making use of it and they don’t find intersections anymore since I updated to version 7.3.21039.11201, 8/02/2021. I used this function just before the update and it worked. The previous Rhino version was from 21/01/2021, if I remember correctly.

It would be great if you could check that. I’m using those scripts frequently in my daily workflow.

Kind regards, Gero.

7 posts - 4 participants

Read full topic

How can I change the color in IronPython?

$
0
0

I am sorry, but Why doesn’t this code work?

import rhinoscriptsyntax as rs
import System

obj = rs.GetObject()
rs.ObjectMaterialSource(obj, 1)
index = rs.ObjectMaterialIndex(obj)
color = System.Drawing.Color.Blue
rs.MaterialColor(index, color)

print("test")

Or

import rhinoscriptsyntax as rs
import Rhino
import System

obj = rs.GetObject()
nColor = System.Drawing.Color.Blue
mat = Rhino.DocObjects.Material()
mat.DiffuseColor = nColor
rMat = Rhino.Render.RenderMaterial.CreateBasicMaterial(mat)
tab = Rhino.RhinoDoc.ActiveDoc.Objects
Rhino.DocObjects.Tables.ObjectTable.ModifyRenderMaterial(tab, obj, rMat)

print("test 2")

Please!!
1.py (225 Bytes)
2.py (270 Bytes)

5 posts - 1 participant

Read full topic

DrawViewportMeshes for technical Drawing

$
0
0

Hello i am working in a Python component and i am implementing the in DrawViewportMeshes method the function Pipeline.DrawBrepShaded and Pipeline.DrawBrepWires to draw a series of Brep. I would like to know if i can setup a material in such a way that it can simulate a tecnical drawing view. or if i can change the behavior depending on tre viewport style
Thanks in advance.
Stefano

2 posts - 2 participants

Read full topic

Viewing all 5868 articles
Browse latest View live