Grasshopper

algorithmic modeling for Rhino

bug in latest build? problem with offset in VBA script

Hi,

last friday I installed the latest grasshopper update (grasshopper_wip_20110307) and I notticed that the VBA-modules in my script where not longer working. The error seems to be in this line:

Dim inner As Curve() = section.ToNurbsCurve().Offset(normal, pc, -plate, 1e-3, 1e-4, Rhino.Geometry.CurveOffsetCornerStyle.Sharp)

the error message is:

"

            {0}0. Error: Het oplossen van de overbelasting is mislukt omdat dit aantal argumenten door geen enkele toegankelijke Offset wordt geaccepteerd. (line 104)

"

this is the VBA script:

"
Option Strict OffOption Explicit On
'Import SDK and Framework namespacesImports RhinoImports Rhino.GeometryImports Rhino.Collections
Imports GrasshopperImports Grasshopper.KernelImports Grasshopper.Kernel.DataImports Grasshopper.Kernel.Types
Imports GH_IOImports GH_IO.Serialization
Imports SystemImports System.IOImports System.XmlImports System.DataImports System.DrawingImports System.ReflectionImports System.CollectionsImports System.Windows.FormsImports Microsoft.VisualBasicImports System.Collections.GenericImports System.Runtime.InteropServices


'Code generated by Grasshopper(R) (except for RunScript() content and Additional content)'Copyright (C) 2011 - Robert McNeel & Associates<System.Runtime.CompilerServices.CompilerGenerated()> _Public Class Script_Instance  Implements IGH_ScriptInstance
#Region "Members"  ''' <summary>List of error messages. Do not modify this list directly.</summary>  Private __err As New List(Of String)
  ''' <summary>List of print messages. Do not modify this list directly, use the Print() and Reflect() functions instead.</summary>  Private __out As New List(Of String)
  ''' <summary>Represents the current Rhino document.</summary>  Private doc As RhinoDoc = RhinoDoc.ActiveDoc
  ''' <summary>Represents the Script component which maintains this script.</summary>  Public owner As Grasshopper.Kernel.IGH_ActiveObject#End Region
#Region "Utility functions"  ''' <summary>Print a String to the [Out] Parameter of the Script component.</summary>  ''' <param name="text">String to print.</param>  Private Sub Print(ByVal text As String)    __out.Add(text)  End Sub
  ''' <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>  ''' <param name="format">String format.</param>  ''' <param name="args">Formatting parameters.</param>  Private Sub Print(ByVal format As String, ByVal ParamArray args As Object())    __out.Add(String.Format(format, args))  End Sub
  ''' <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>  ''' <param name="obj">Object instance to parse.</param>  Private Sub Reflect(ByVal obj As Object)    __out.Add(GH_ScriptComponentUtilities.ReflectType_VB(obj))  End Sub
  ''' <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>  ''' <param name="obj">Object instance to parse.</param>  Private Sub Reflect(ByVal obj As Object, ByVal method_name As String)    __out.Add(GH_ScriptComponentUtilities.ReflectType_VB(obj, method_name))  End Sub#End Region
  ''' <summary>  ''' This procedure contains the user code. Input parameters are provided as ByVal arguments,  ''' Output parameter are ByRef arguments. You don't have to assign output parameters,  ''' they will be null by default.  ''' </summary>  Private Sub RunScript(ByVal p0 As Point3d, ByVal p1 As Point3d, ByVal p2 As Point3d, ByVal pc As Point3d, ByVal plate As Double, ByVal itt As Integer, ByVal dev As Double, ByRef crvout As Object, ByRef crvin As Object, ByRef sec As Object, ByRef opp As Object, ByRef div As Object, ByRef pt4 As Object)     'your code goes here…    opp = "test01"    Dim section As New Polyline(5)    section.Add(p0)    section.Add(p1)    section.Add(p2)    section.Add(pc)    section.Add(p0)    Dim normal As Vector3d = vector3d.CrossProduct((p1 - p0), (p2 - p0))    Dim area As Double    Dim chicken_int As Int32 = 0    Dim XX As Double    Dim YY As Double    Do      chicken_int += 1      If (chicken_int > itt) Then Exit Do
      'Compute the section offset      Dim inner As Curve() = section.ToNurbsCurve().Offset(normal, pc, -plate, 1e-3, 1e-4, Rhino.Geometry.CurveOffsetCornerStyle.Sharp)      Dim edges As New CurveList(inner)      edges.Add(section.ToNurbsCurve())      crvin = edges
      Dim sections As Brep() = Brep.CreatePlanarBreps(edges)      If (sections Is Nothing) Then Exit Do      opp = "test02"
      'Compute the centroid of the current section      Dim am As AreaMassProperties = AreaMassProperties.Compute(sections(0))      Dim ct As Point3d = am.Centroid
      XX = am.CentroidCoordinatesMomentsOfInertia.X      YY = am.CentroidCoordinatesMomentsOfInertia.Y      area = am.Area      Dim dx As Vector3d = pc - ct
      'Compute the error of the current centroid      Dim dl As Double = dx.Length      div = dl      'Update output values      crvout = section      crvin = inner      sec = sections(0)      opp = area      If (dl < dev) Then Exit Do
      'Adjust outline with a boosting factor.      section(3) += dx * 4

    Loop    pt4 = section(3)    crvout = section

  End Sub 
  '<Custom additional code> 
  '</Custom additional code> 
End Class

"

Views: 461

Attachments:

Replies to This Discussion

Hoi Piet,

 

het kan zijn dat de functie is veranderd in RhinoCommon. Ik kan me niet herinneren dat dat is gebeurd, maar de foutmelding laat weinig andere opties toe.

 

Je gebruikt twee tolerantie waardes (1e-3 & 1e-4) maar alle Offset functies die ik kan vinden accepteren er maar één. Ik denk dat als je de tweede eruit schopt dat het dan weer werkt.

 

Als je tot voor kort een relatief oude versie gebruikt hebt let dan op. Er is een bug in de Offset functie. Heb ik onderhand gerepareerd maar komt pas beschikbaar bij de volgende versie (had afgelopen vrijdag al moeten zijn, maar ik loop een paar dagen achter op de planning).

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Dag David,

dank u voor het snelle (en correcte) antwoord. ik had al de vorige versie van GH terug gezet maar zat met een aantal problemen van backward compatibility (ik had verder gewerkt in de laatste versie... ) blijkbaar heb je gewerkt aan de 'move' en 'rotate around axis' componenten want daar had GH problemen mee?

Enfin, ik ben nu weer bezig met de nieuwste versie en heb de offset parameters nu juist ingevuld. Blijkbaar moet er toch iets gewijzigd zijn in rhinocommon want in de vorige versie werkte dit wel. (Het script zelf is ook mede samengested op dit forum, ik ben geen expert in vba en rhinocommon functies...)

 

Dus de problemen zijn voorlopig van de baan. nogmaals dank voor de snelle hulp!

 

groet

 

Piet

 

hallo David,

ik heb deze morgen de laatste GH versie gedownload (grasshopper_wip_20110412) en heb opnieuw problemen met het VBA script. Dit was aangepast aan de vorige GH versie (grasshopper_wip_20110307) en werkte daar wel weer volledig. Ik ben dus nu weer overgeschakeld op deze versie en kan voorlopig verder. de foutmelding was iets in de zin van

'... dit wijst er meestal op dat het geheugen beschadigd is...'

(ik kan het niet meer reconstrueren want zit terug in de vorige versie.)

 

Ik ben zoals eerder gezegd niet zo thuis in rhinocommon en vba maar vind het wel vreemd dat ik in alle scripts tot nu toe het volgende schreef (dat werkte):

.Offset(3dvectort(normal)center, thickness, tolerance, tolerance, Rhino.Geometry.CurveOffsetCornerStyle.Sharp)

In grasshopper_wip_2011030 werkte dit niet meer en heb ik dit veranderd in:

.Offset(center, 3dvectort(normal), thickness, tolerance, Rhino.Geometry.CurveOffsetCornerStyle.Sharp)

 

Misschien is er weer een fout in deze regel? Ik kan gerust verder werken met de vorige versie dus voor mij is dit geen probleem, ik wou je dit alleen maar melden.

 

groeten

 

Piet

Attachments:

Hoi Piet,

 

er is iets verschrikkelijk mis met de Curve Offset functie in de SDK. Het is een nieuw probleem maar het is nog niet duidelijk wat de oorzaak is. Zodra ik het gevonden heb komt er onmiddelijk een nieuwe versie uit.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service