Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all 8667 articles
Browse latest View live

Basic Point Addition

$
0
0

@Jonathan_Hutchinson1 wrote:

import Rhino
import rhinoscriptsyntax as rs

crv = rs.GetObject()
pts = rs.BoundingBox(crv)

print pts
print "Point 1 is " + str(pts[0])
print "Point 2 is " + str(pts[1])

pointAdd = Rhino.Geometry.Point3d(0,0,0)

pointAdd = pointAdd.Add(pointAdd, pts[0])
print "Origin + Point 1 is " + str(pointAdd)

pointAdd = pointAdd.Add(pointAdd, pts[1])
print "Point 1 + Point 2 is " + str(pointAdd)


for i in pts:
    pointAdd += pointAdd.Add(pointAdd, (pts[i]))

print pointAdd

Message: expected index value, got Point3d

Sorry… really basic one here. I don’t see where it’s expecting an index. At least, where it’s expecting an index I’m giving it one. Trying to get the centroid of a Bounding box. I was having some issues with ‘type’ earlier too. I think I’m just not treating methods/properties right.

All the print statements were just me checking I was at least doing the addition right. It’s the for loop which I’ve not defined very well.

Posts: 3

Participants: 2

Read full topic


Delete duplicate objects

How does the Notes panel work?

$
0
0

@ludovick wrote:

Hi All,

I’m trying to make a panel with textboxes in it and have the content follow the file like the Notes Panel does it. Not saving them in the template. Is it possible?

I’m working with c# in Visual Studio.

Thanks a lot,

Posts: 2

Participants: 2

Read full topic

Lock or Protect Attribute User Text?

$
0
0

@ed.p.may wrote:

Hi All,

I’m wondering if there is a way to ‘lock’ or protect the Rhino 6 Attribute User Text that is easy to implement within a script? In particular, the ‘Object Name’ is a causing a bit of a problem for me at the moment:

I have a short script and dialogue window to accept/set a series of user-determined parameters which are applied to an object and stored in Attribute User Text fields. That all works fine and in my script I can set the object name in the Attribute User Text using the line:


rs.SetUserText(objectInstance, ‘Object Name’, ‘%<ObjectName("{}")>%’.format(str(objectInstance)))

to ‘set’ the Object Name in the Attribute User Text properly using the script. This seems to mimic the action of the ‘Text Field’ button and selecting ‘Object Name’ from the list. So if the name is updated in the ‘Properties’ it auto-updates in the Attribute User Text which is good.


The problem comes later on, as the user is working away and the Attribute User Text panel is there, it’s easy to accidentally try and rename the Object through the Attribute User Text panel, rather than back on the ‘Properties’ panel. This then breaks the link and causes problems down the line…

So, is there any easy way to ‘lock’ or ‘protect’ the Attribute User Text from accidental overwriting? I’d like the user to be able to see the params as they work, just not be able to (try and) overwrite the object name through the panel - only through the pop-up dialog that I’m writing or on the Properties dialogue.

Any thoughts on how to implement such a protection are much appreciated!!
thanks,
-Ed

Posts: 1

Participants: 1

Read full topic

Bug in Transform.Scale(Plane, double, double, double)

$
0
0

@laurent_delrieu wrote:

Hello
I want to transform a sphere to an ellipsoid. So I use Transform.Scale(Plane plane, double x, double y, double z). It appears that I have no effect of y, and same effect of x and y.

    Sphere sphere = new Sphere(Point3d.Origin, 100);
    //Brep ellipsoid = sphere.ToBrep();
    Brep ellipsoid = Brep.CreateFromSphere(sphere);

    ellipsoid.Transform(Transform.Scale(Plane.WorldXY, aa, bb, cc));

    A = ellipsoid;


bug transform.gh (3.0 KB)

I use
Version 6 SR22
(6.22.20009.23271, 01/09/2020)
Commerciale
Version 6 SR24
(6.24.20055.18581, 02/24/2020)
Work In Progress
(7.0.20056.13055, 02/25/2020)

Posts: 1

Participants: 1

Read full topic

Dock panel resize

$
0
0

@MatrixRatrix wrote:

Hello ,

I have a Custom dockpanel like (sampleCsDockpanle) and
I need resize this dockpanel (user control), I already try “this.Width = 250;” but seams make
no efect.

Any tip?

Posts: 1

Participants: 1

Read full topic

Use RhinoCommon(python) to select all objects in Rhino file

$
0
0

@jason.danforth wrote:

I’m sure this is incredibly simple but I haven’t been able to get it to work…

I have a Rhino file with several objects (points, breps, lines, etc.). I’d like to be able to access these objects in a python component using RhinoCommon, so that I can use them as if they had been referenced in Grasshopper (i.e. I can Transform them, visualize them, or call any of the usual methods associated with their relevant class).

I’ve tried things like Rhino.DocObjects.BrepObject.Geometry, but that just returns a IronPython.Runtime.Types.ReflectedProperty, not the geometry. I’ve also tried Rhino.DocObjects.ObjRef() and entered the guid as the argument, but I can’t seem to format the string as a guid… Any help would be greatly appreciated.

Thanks!

Posts: 2

Participants: 2

Read full topic

Layer full path not correct when using "Move Up One Parent" in Rhino's layer panel

$
0
0

@jukka.maenpaa wrote:

I am using LayerTableEvent to check when the layer table is modified. When I use “Move Up One Parent” in Rhino’s layer panel (see the upper image) then the full path of the layer in old state is same as in the new state. So the old full path of the layer is not correct since it is same as the new full path (see the lower image)

image

Posts: 1

Participants: 1

Read full topic


Execute method if new document is created

$
0
0

@Felix1 wrote:

I like to execute a method of my plugin if a new document is created. Not if a existing document is loaded, only if a new one is created.

I think i should use

    protected override LoadReturnCode OnLoad(ref string errorMessage)
        {
            RhinoDoc.NewDocument += OnNewDocument;
            return LoadReturnCode.Success;
        }

    public static void OnNewDocument(object sender, DocumentEventArgs e)
    {
        RhinoApp.WriteLine("NewDocument");
        //var dialog = new ProjectData(e.Document);
        //dialog.RestorePosition();
        //dialog.ShowModal(RhinoEtoApp.MainWindow);
        //dialog.SavePosition();
    }

but the WriteLine is never printed. What do i miss.

Posts: 2

Participants: 2

Read full topic

Get Left, Back, Bottom views in C++

$
0
0

@Pablo_Garcia-Amorena wrote:

Hi,

I have an issue similar to Get Left, Back and bottom views using python script in C++: how do I get Left, Back and Bottom pre-defined views, when they are not currently in the document set of views?

Normally I’d do something like

ON_3dmView views[4];

bool foundPerspective = context.m_doc.FindView(L"Perspective", views[0]);
bool foundBottom = context.m_doc.FindView(L"Bottom", views[1]);
bool foundBack = context.m_doc.FindView(L"Back", views[2]);
bool foundLeft = context.m_doc.FindView(L"Left", views[3]);

But these are false when the views are not currently in the document. How to get them regardless of the current document views?

Thanks,
Pablo

Posts: 1

Participants: 1

Read full topic

Customize view drop-down menu?

$
0
0

@Pablo_Garcia-Amorena wrote:

Hi,

In the context of creating a custom skin, I wonder if it’s possible to customize the drop-down menu that we get when clicking on the arrow next to a view name:

I would simplify it by only showing the available views (the options in Set View), or just the named views. Maybe this is possible or could be requested?
If not possible, it would be great to have at least the option to remove the clickable arrow that leads to the drop-down menu.

Thank you,
Pablo

Posts: 1

Participants: 1

Read full topic

AngularDimension set DefPoint bug

$
0
0

@clement wrote:

Hi @dale,

there seems to be a bug in setting DefPoint1 and DefPoint2 of an AngularDimension. If the new point is on a line which would not change the angle of the angular dimension, the DefPoint is not set. Below image shows what i want to do. DefPoint1 (A) should be moved to point B without changing the angle of the dimension object.

I’ve found that i can trick it by first moving it away and then back (see commented out code):

def DoSomething():
    
    dim_id = rs.GetObject("AngDim", rs.filter.annotation, True, False)
    if not dim_id: return
    
    ang_dim = rs.coercerhinoobject(dim_id, True)
    
    pt = rs.GetPoint("DefPoint1")
    if not pt: return
    
    _, s, t = ang_dim.Geometry.Plane.ClosestParameter(pt)
    
    # this fails
    ang_dim.Geometry.DefPoint1 = Rhino.Geometry.Point2d(s, t)
    
    # this works
    #ang_dim.Geometry.DefPoint1 = Rhino.Geometry.Point2d(s+0.01, t+0.01)
    #ang_dim.Geometry.DefPoint1 = Rhino.Geometry.Point2d(s-0.01, t-0.01)
    
    ang_dim.CommitChanges()

DoSomething()

Here is the file: DefPointBug.3dm (38.6 KB)

Please note that i want to set these points before adding the AngularDimension to the document. Above example is just for illustration of the bug.

EDIT: I’ve found AdjustFromPoints which seems to allow to set DefPoint properly, but it required conversion from 2d to 3d.
_
c.

Posts: 2

Participants: 2

Read full topic

Python, Not Returning Result Outside Function

$
0
0

@Jonathan_Hutchinson1 wrote:

#SelectSurfaceCornerGrips

import rhinoscriptsyntax as rs

srf = rs.GetSurfaceObject('Select a surface for corner point display', preselect=True)
if srf:
    srf = srf [0]

srfPtCount = rs.SurfacePointCount(srf)
uCount = srfPtCount [0]
vCount = srfPtCount [1]
srfPtCount = uCount*vCount

#Report the total number of points, Yes/No option?
def PrintSurfacePointCount():
    
    print "Point Count: " + (str(srfPtCount))
    print "U Count: " + str(uCount) 
    print "V Count: " + str(vCount)


def SelectSurfaceCornerGrips(srf):
    
    #u is a row index, with a total of 'v' points, Corners at (u0, u1, u2, u3)
    u1index = uCount-1 # Zero based, final point of first row
    u3index = srfPtCount-1 #Zero based, final point of the surface
    
    rs.EnableObjectGrips(srf)
    u0 = rs.SelectObjectGrip(srf, 0)
    u3 = rs.SelectObjectGrip(srf, u3index)
    u1 = rs.SelectObjectGrip(srf, vCount-1)
    u2 = rs.SelectObjectGrip(srf, srfPtCount-vCount)
    
    p0 = rs.ObjectGripLocation(srf, 0)
    p1 = rs.ObjectGripLocation(srf, u3index)
    p2 = rs.ObjectGripLocation(srf, vCount-1)
    p3 = rs.ObjectGripLocation(srf, srfPtCount-vCount)

    points = (p0, p1, p2, p3)
    return points

SelectSurfaceCornerGrips(srf)

print points

if points:
    rs.AddPoints(points)

PrintSurfacePointCount()

#Option for Creating Points VS Selecting the Points
#Will it work for 3 sided surfaces?

I’m trying to clean up some of my early code trials and learning by trying functions. I thought I was using return properly, to return the result of some arguments in my function SelectSurfaceCornerGrips function to use later on. In return points and then print points, it becomes clear I haven’t used it correctly. It worked before anyway as a line by line piece of code, so I’ve kind of taken a step backwards by adding the functions, for now.

Any help appreciated!

Posts: 1

Participants: 1

Read full topic

Dynamic Redraw, a Subsurface Interval

$
0
0

@Jonathan_Hutchinson1 wrote:

Is there anything in the API to enable the visualisation of making a rectangular subsurface, on a surface? In a similar way to how the extractIsocurve command visualises the straight isocurve, except defining another point in which to make a UV shaped rectangle.

I can see where I would change to the crosshairs for better picking of the first point under Rhino.UI Cursor Style.

Posts: 1

Participants: 1

Read full topic

Batch Printing And Exporting to PDF using Python

$
0
0

@dcomeau wrote:

How is it going everyone! I have been using Rhino for around two years now and have just started to play around with Python Scripts. For my line of work I end up printing a lot of layouts as well as export them to a pdf so the rest of my coworkers can easily observe my documentation (Ones who dont use Rhino). After a couple days messing around with Rhnio’s editpythonscript command I came up with two scripts that open and export and or print any Rhino file in that directory. This was designed for people who use layouts. Also I am fairly new to python code so if there is a better way constructive feedback is always appreciated. When I was looking for information about batch printing I could not find any simple python scripts, these are really simple and should be easy to follow. All you have to do is place the script in the directory with all the rhino files you want exported or printed. Then open any rhino file (a new file is best) and enter editpythonscript, once the Rhino Python Editor is open, open the script located in the directory that you placed it in and hit that play button or F5! Hope you all enjoy I know this will be saving me quite a bit of time.

All the best,
Derek

Export Rhino Files to PDF.py (1.1 KB) Print Rhino Files.py (821 Bytes)

Posts: 1

Participants: 1

Read full topic


Unable to Click to Select ComboBox Options

$
0
0

@zberzolla wrote:

When using a combo box in a plug-in interface, I have to use the enter key on my keyboard to select an option; a mouse click does not work. Is there a specific setting/method to enable hand-clicking?

The combo box is instantiated using:
public void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBoxItem cbi = new ComboBoxItem();
}

Below is the code snippet from the .xaml file (with some “<”):

"<"ComboBox x:Name=“comboBoxFT” HorizontalAlignment=“Left” Margin=“146,44,0,0” VerticalAlignment=“Top” Width=“120” SelectionChanged=“ComboBox_SelectionChanged” Cursor=“Hand”>
“<” ComboBoxItem Content=“a” Cursor=“Hand”/>
"<"ComboBoxItem Content=“b” Cursor=“Hand”/>
“<“ComboBoxItem Content=“c” Cursor=“Hand”/>
</ComboBox”>”

Posts: 1

Participants: 1

Read full topic

Best practice saving password from custom plugin optionpage

$
0
0

@Felix1 wrote:

Im writing an plugin where the user need to fill in his password for a webservice. I already add a custom optionpage and save other options in the plugin.Settings but they a viewable in the advance_optionpage. Where are the best place to save this password permanently and hidden.

Posts: 1

Participants: 1

Read full topic

Export only visible layers from block instances

$
0
0

@l.m.tramontini wrote:

I have a project with hundreds of unique blocks, each of which has components on 5 layers. How would I go about exporting the block instances, but excluding objects from certain layers (for example exporting only from visible layers) in python?

relatively new to python.
Any help is appreciated, Cheers!

Posts: 1

Participants: 1

Read full topic

Is there a way of targeting a version of Rhinocommon by feature?

$
0
0

@jacobblitzer wrote:

Is there a way of targeting a version of Rhinocommon by feature? Specifically, find coincident Brep Components is not supported in every version of Rhinocommon, and I want to build a plugin on the earliest version that supports this feature.

Posts: 10

Participants: 4

Read full topic

Setup a simple relation between objects and undo behaviour

$
0
0

@software_comas wrote:

Hi!
I have to develop a plugin that is able to create and mantain a simple relation between objects.
More in dept, I want to create a surface (let’s call it “S”) using 2 input curves (let’s call them “C1” and “C2”).
It doesn’t matter how “S” is created but, at the time of its creation, I automatically add information about all the obejcts involved in the operation (and some extra parameters) inside all objects user dictionaries.
Now I’m able to update the “S” surface if one or both curves “C1” and C2" are modified someway, even if the curves are modified by another command.
Everything is working fine except when I’m going to undo the operation: it looks like the “S” surface update is not saved inside Rhino undo stack.
I tried to use commands like BeginUndoRecord/EndUndoRecord, wrapping surface updating, but it seems I get another undo entry in Rhino undo stack: I have to press undo twice to come back to the original document status.
Is there some way to “merge” all the operations in a single one, so that undoing them requires just a single “undo” execution?
Do you know a better/different way to setup a relation like the one I need?
Thanks a lot.

Sebastiano

Posts: 2

Participants: 2

Read full topic

Viewing all 8667 articles
Browse latest View live