DirectGrid issue [fixed on CVS]

I dunno if I’m talking about a feature still supported by the dev team but today it happens I need a grid into my app, similar to that we see on 3d editing programs, so first I gave a glimpse into P3D API and found what I need but…broken. So I tried to fix it by myself changing the code inside the module direct.directtools.DirectGrid from this:

004 from DirectUtil import *
005 from DirectGeometry import *
055 self.reparentTo(

to this:

004 from direct.directtools.DirectUtil import *
005 from direct.directtools.DirectGeometry import *
055 self.reparentTo(render)

Dunno If is a correct way to fix it (I bet not) but ‘actually’ it works for me.

In what way did it fail before? The import statements should have been all right, since is itself within direct.directtools.

The reparentTo() is assuming that the DirectTools gui has already been started. If it hasn’t, then it will fail because hasn’t been created yet. I went ahead and checked in a new option that allows you to specify the parent you want (so you can pass in parent=render to the grid.enable() call, for instance).


here the traceback David:

  File "", line 215, in <module>
  File "", line 205, in __init__
  File "linuxroot/usr/share/panda3d/direct/src/directtools/", line 52, in __init__
  File "linuxroot/usr/share/panda3d/direct/src/directtools/", line 55, in enable
AttributeError: 'NoneType' object has no attribute 'group'

yes I guess you’re right about the imports - I had to modify 'em cause I’d put the DirectGrid class in my app to work on it.
Though I guess I can’t apply your solution cause the code breaks himself instancing the class, but maybe simply I ain’t get it how to apply it.

Ah, you’re right, sorry. I just checked in a further fix that allows you to pass in the parent to the constructor as well.


so if I get it, you mean that instancing like this DIrectGrid(render) it will fix it? But I just tried this before and I got the same tb:

but if if you’re fine with that I’m starting to think that I’ve to download and build (dang!) the 1.5.3 (I’m actually on 1.5.2) cos I guess you guys changed something related. I’ll do and report back ASAP.

Actually, between 1.5.2 and 1.5.3 nothing has changed to that file – David just brought in the fix to CVS: … y?view=log
You can click the top “download” link (for HEAD) to grab the latest version of this file – then, you can add ‘parent=render’ to the constructor.

you clarification was indeed needed pro-soft, I aint got that David was fixing on-the-fly, thankyou

one last thing: I tried the fresh DirectGrid and found errors loading the models - note that the former and broken had not the .bam extension on those and was fine with that. Fixing it all works good.

Really? I guess we distribute egg files with the publish, and not bam files? OK, I’ll change it back and remove the .bam extension. Sorry about that.


i was playing around with the DirectGrid module today, but i just can’t get it to work.
i already wrote my own class for drawing grids, but it’s kind of inventing the wheel a second time. (and the panda module is better, i think)

do i really need to start up the DirectTools gui for this? (as suggested by David)

        dg = DirectGrid()
        dg.enable(render)  # argument is parent

results in a

  File "/opt/panda3d/direct/src/directtools/", line 51, in __init__
    self.enable(parent = parent)
  File "/opt/panda3d/direct/src/directtools/", line 57, in enable
AttributeError: 'NoneType' object has no attribute 'group'

(actually it shouldn’t even come to this line) and

        class mygrid(DirectGrid):
            def __init__(self):
        mg = mygrid()

gives a

  File "/opt/panda3d/direct/src/directtools/", line 59, in enable
  File "/opt/panda3d/direct/src/directtools/", line 78, in updateGrid
AttributeError: 'mygrid' object has no attribute 'minorLines'

i’m really confused about that and also the newest CVS version of the isn’t really updated (only one really minor changes)

so is it possible to work with that module independent of any other (direct)tools?

You have to give parent=render to the constructor and enable function.

ouch! i tried adding the parent argument to both, but i forgot to try with both at the same time…

thx pro-rsoft!