Grasshopper

algorithmic modeling for Rhino

Hello,

I am a beginner in Python trying to create a surface by lofting 2 polylines.

I am inputting 2 polylines and my input parameters are set as "Item Access" and the Type hints are set to "Curve". Do you know why am I getting a null output and the surface doesn't get created? 

Thanks,

Naciem

Views: 1490

Attachments:

Replies to This Discussion

Do you have reason, that you will loft the curves with Python?

GH Default Loft Component can already create Loft Surface from Polylines.

I am just learning python and thought using grasshopper python component would be easier for me to learn since it is more visual and I can see step b step if my code is working...Also Python is a course that I am taking.

n- 

I think...

1. you need to feed your curves in one list. not each other.

2. assign your access type as list in python component.

3. feed your curves to python component.

See Rhino IronPython Document.

Syntax

rhinoscriptsyntax.AddLoftSrf ( object_ids, start=None, end=None, loft_type=0, simplify_method=0, value=0, closed=False )

rhinoscript.surface.AddLoftSrf ( object_ids, start=None, end=None, loft_type=0, simplify_method=0, value=0, closed=False )

Hi Naciem,

Yong Sung is correct but you can make the current script work as well. Like: rs.AddLoftSrf((HEX1, HEX2))[0]

As a side note. You don't need to change the Type Hint. You can just leave it as ghDoc object.

Hi Mostapha,

Thank you for your response. Can you please explain to me why you would write it as ((HEX1, HEX2))[0]. 

I knew that it has to be a list and I was using ([HEX1], [HEX2]).

Thanks,

Naciem

Hi Naciem,

[HEX1], [HEX2] are two different lists that each one has one member. What you need is a list with two members (both curves). That is why I wrote it as [HEX1, Hex2]. In this way  AddLoftSrf takes the list as object_ids.

In case of ([HEX1],[HEX2]) AddLoftSrf takes [HEX1] as the first input which is object_ids and [HEX2] as the second input which is start. That's why you get no surface.

Mostapha

Mostapha

Mostapha,

The first time you wrote ((HEX1, HEX2))[0]. I also just tested [HEX1, Hex2] which works fine. How does python read and accept ((HEX1, HEX2))[0] as well when HEX1 and HEX2 are not a list, but 0 is? How did you know we need to add [0] to make it work?

I'm sorry with all these primitive questions.

Thanks,

Naciem

rs.AddLoftSrf will return a List of created Surfaces.

It means...

srfList =  rs.AddLoftSrf((HEX1, HEX2))

and the meaning of  rs.AddLoftSrf((HEX1, HEX2))[0]

is the first item in srfList. it is equal to srfList[0]

1. (a,b) makes a tuple whereas [a,b] makes a list in Python:

"Though tuples may seem similar to lists, they are often used in different situations and for different purposes. Tuples are immutable, and usually contain an heterogeneous sequence of elements that are accessed via unpacking (see later in this section) or indexing (or even by attribute in the case of namedtuples). Lists are mutable, and their elements are usually homogeneous and are accessed by iterating over the list."

In this case it doesn't really matter and both (HEX1, HEX2), [HEX1, HEX2] work the same for you.

 

2. As Yong Sung posted rs.AddLoft returns a list of surfaces, so I used [0] to get the first item of the list.

Mostapha and Yong Sung,

Thank you so much for all you explanations. You've been very helpful!

Make the same change in your script and it will work. Line 64.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service