Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant get geometry script to work on blender 3.5 #20

Open
MrPositivity opened this issue Apr 18, 2023 · 6 comments
Open

Cant get geometry script to work on blender 3.5 #20

MrPositivity opened this issue Apr 18, 2023 · 6 comments

Comments

@MrPositivity
Copy link

MrPositivity commented Apr 18, 2023

I'm trying out Geometry Script, but I can't get it to work.
when I run the script for Repeat Grid.py its not making node tree correctly like in image in the documentation, not sure what is wrong
It looks like this - https://i.imgur.com/7jXvyIH.png

am I missing something?
it also gives this error when I press Run Script

Python: Traceback (most recent call last):
 File "C:\Users\Positivity\Desktop\GN_Test01.blend\Repeat Grid.py", line 4, in <module>
 File "C:\Users\Positivity\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\geometry-script-main\api\tree.py", line 98, in build_tree
   outputs = builder(**builder_inputs)
 File "C:\Users\Positivity\Desktop\GN_Test01.blend\Repeat Grid.py", line 8, in repeat_grid
TypeError: 'NoneType' object is not callable
@carson-katri
Copy link
Owner

Some nodes changed in Blender 3.5, you may need to add .mesh after the call to grid(…):

from geometry_script import *

@tree("Repeat Grid")
def repeat_grid(geometry: Geometry, width: Int, height: Int):
    g = grid(
        size_x=width, size_y=height,
        vertices_x=width, vertices_y=height
    ).mesh.mesh_to_points()
    return g.instance_on_points(instance=geometry)

@TheOtherRealm
Copy link

I can confirm that it is an issue with 3.5 - works great in 3.4.1

@HUisHU-Christian
Copy link

It doesn't seem to be working in Blender 3.6 as well. Is there a fix for this already or are there any plans for fixes soon or do we need to patch this on ourself?

@HUisHU-Christian
Copy link

To answer my own question: The main branch does have the fixes applied and it seems to be working. It's just that a recent release seems to be missing. Maybe it's time for a new release now that blender 3.6 is out?

@HUisHU-Christian
Copy link

Well it installs, but the example script refused to run (for the same reasons):
TypeError: 'NoneType' object is not callable

@naccio8
Copy link

naccio8 commented Aug 2, 2023

Yes in 3.5 and 3.6 some node was be changed, I have correct the two official Tutorial: City Builder and Voxelize for the 3.6 LTS:

Voxelize

from geometry_script import *

@tree("Voxelize")
def voxelize(geometry: Geometry, resolution: Float = 0.2):
    return geometry.mesh_to_volume(
        interior_band_width=resolution,
        fill_volume=False
    ).distribute_points_in_volume(
        mode=DistributePointsInVolume.Mode.DENSITY_GRID,
        spacing=resolution
    ).instance_on_points(
        instance=cube(size=resolution).mesh
    )

City Builder

from geometry_script import *

@tree("City Builder")
def city_builder(
    geometry: Geometry,
    seed: Int,
    road_width: Float = 0.25,
    size_x: Float = 5, size_y: Float = 5, density: Float = 10,
    building_size_min: Vector = (0.1, 0.1, 0.2),
    building_size_max: Vector = (0.3, 0.3, 1),
):
    # Road mesh
    yield geometry.curve_to_mesh(profile_curve=curve_line(
        start=combine_xyz(x=road_width * -0.5),
        end=combine_xyz(x=road_width * 0.5)
    ))
    # Building points
    building_points = grid(size_x=size_x, size_y=size_y).mesh.distribute_points_on_faces(density=density, seed=seed).points
    road_points = geometry.curve_to_points(mode=CurveToPoints.Mode.EVALUATED).points
    # Delete points within the curve
    building_points = building_points.delete_geometry(
        domain=DeleteGeometry.Domain.POINT,
        selection=geometry_proximity(target_element=GeometryProximity.TargetElement.POINTS, target=road_points, source_position=position()).distance < road_width
    )
    # Building instances
    
    yield building_points.instance_on_points(
        instance=cube().mesh.transform_geometry(translation=(0, 0, 0.5)),
        scale=random_value(data_type=RandomValue.DataType.FLOAT_VECTOR, min=building_size_min, max=building_size_max, seed=seed),
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants