Grasshopper

algorithmic modeling for Rhino

Dear Grasshopper-Community,

I am trying for days to integrate the "MergeFields" component into a Python-Script, but for some reason it always gives me the error as following:
"Runtime error (MissingMemberException): 'Param_Field' object has no attribute 'PersistentData'"

Does anyone know what I did wrong?

Attached: Code+GH-File

import rhinoscriptsyntax as rs
import random as rnd
import ghpythonlib.components as gc
import Rhino.Geometry as rg
import Grasshopper.Kernel as gk


AttPt = []
AttSp = []
AttSpP = []
for i in range(5):
    xPopGeo3D = rnd.randint(0,250)
    yPopGeo3D = rnd.randint(0,250)
    zPopGeo3D = rnd.randint(0,250)
    PopGeo = rs.AddPoint(xPopGeo3D,yPopGeo3D,zPopGeo3D)
    AttPt.append(PopGeo)
    SPA = rs.AddSphere(PopGeo,5)
    AttSp.append(SPA)

DttPtList = []
for i in range(5):
    xDttPt = rnd.randint(0,250)
    yDttPt = rnd.randint(0,250)
    zDttPt = rnd.randint(0,250)
    DttPt = rs.AddPoint(xDttPt,yDttPt,zDttPt)
    DttPtList.append(DttPt)

TgPtList = []
TgSpList = []
TgChList = []
PtChFieldList = []
MergedFieldList = []

for i in range(4):
    TgPointAx = rnd.randint(50,200)
    TgPointAy = rnd.randint(50,200)
    TgPointAz = rnd.randint(50,200)
    TgPtSp = gc.ConstructPoint(TgPointAx,TgPointAy,TgPointAz)
    #Point
    TgPtList.append(TgPtSp)
    #Sphere
    TgSp = gc.Sphere(TgPtSp,5)
    TgSpList.append(TgSp)
    #Point Charge
    field = gk.Types.GH_Field()
    TgPtCh = gc.PointCharge(TgPtSp,50,2)
    PointChList = field.Elements.AddRange(TgPtCh)
    PtChFieldList.append(field)



for i in range(4):
    #Field Merge
    Mfield = gk.Types.GH_Field()
    MergedField = gc.MergeFields(PtChFieldList)
    #MergedFieldList.append(MergedField)







#print TgChList
TgSpList_PopulateGeometry = gc.PopulateGeometry(TgSpList,5)
#print TgSpList_PopulateGeometry

Views: 841

Attachments:

Replies to This Discussion

Hi Philipp

I see about this issue. MergeFields does not work in ghcomponentlib, because the underlying parameter type does not accept fields to be stored as PersistentData (fields cannot be stored).

I am attaching a workaround: we just create one field, and then add the results of PointCharge directly to it. This way we do not need to merge anything later.

I will let Steve know about this issue in ghcomponentlib.

Thanks for letting us know. Feel free to ask rather than get stuck with ghcomponentlib; it is still an experimental library.

Enjoy the ride,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Attachments:

Giulio,

Thank you for your quick reply. So I guess same then for ghpythonlib.components.FieldLine(), right?

Yes, just use the native component and then in case a new script.

I recorded the bug here.

Thanks,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

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