THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 11:51, xxxxxxxx wrote:
ok heres the code iv have written so far with the error point pointed to and error pointed to.
Ray
import c4d, os, sys,random
from c4d import plugins, utils, bitmaps, gui, documents,modules
Plugin_ID=1000009 # Testing id ONLY!!!!!!!
#enums
ButtonInfo_X_Vector = 1098
ButtonInfo_Y_Vector = 1099
ButtonInfo_Z_Vector = 1010
Button_X_Vector = 1008
Button_Y_Vector = 1009
Button_Z_Vector = 10010
Button1 = 100011
Button2 = 100012
Button3 = 100013
Button4 = 100014
Button5 = 100015
Button6 = 100016
Button7 = 100017
Button8 = 100018
Button9 = 100019
Button10 = 100020
Button11 = 100021
Button12 = 100022
ButtonInfo1 = 100031
ButtonInfo2 = 100032
ButtonInfo3 = 100033
ButtonInfo4 = 100034
ButtonInfo5 = 100035
ButtonInfo6 = 100036
ButtonInfo7 = 100037
ButtonInfo8 = 100038
ButtonInfo9 = 100039
ButtonInfo10 = 100040
ButtonInfo11 = 100041
ButtonInfo12 = 100042
count=0
class MyDialog_Gui(gui.GeDialog) :
def CreateLayout(self) :
bc = c4d.BaseContainer() #Create a new container to store the image we will load for the button later on
self.GroupBegin(0, c4d.BFH_SCALEFIT|c4d.BFH_SCALEFIT, 2, 1, "Ecco Land Scape Generator.",0) #id, flags, columns, rows, grouptext, groupflags
self.GroupBorderNoTitle(c4d.BORDER_GROUP_OUT)
self.GroupBorder(c4d.BORDER_GROUP_TOP)
self.GroupBorderSpace(left = 2, top=2, right=2, bottom=2)
self.AddStaticText(ButtonInfo1, c4d.BFH_SCALEFIT,name="Click To Regenarate Landscape ",borderstyle=c4d.BORDER_NONE )
self.AddButton(Button1, c4d.BFH_LEFT, name="Click")
self.AddStaticText(ButtonInfo_X_Vector, c4d.BFH_SCALEFIT,name="X Width.",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button_X_Vector, c4d.BFH_LEFT,60,0)
self.SetMeter(Button_X_Vector,600)
self.AddStaticText(ButtonInfo_Y_Vector , c4d.BFH_SCALEFIT,name="Y Hieght.",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button_Y_Vector, c4d.BFH_LEFT,60,0)
self.SetMeter(Button_Y_Vector,100)
self.AddStaticText(ButtonInfo_Z_Vector, c4d.BFH_SCALEFIT,name="Z Depth.",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button_Z_Vector, c4d.BFH_LEFT,60,0)
self.SetMeter(Button_Z_Vector,600)
self.AddStaticText(ButtonInfo2, c4d.BFH_SCALEFIT,name="Width Segments. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button2, c4d.BFH_LEFT,50,0)
self.SetLong(Button2,600)
self.AddStaticText(ButtonInfo3, c4d.BFH_SCALEFIT,name="Depth Segments. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button3, c4d.BFH_LEFT,50,0)
self.SetLong(Button3,600)
self.AddStaticText(ButtonInfo4, c4d.BFH_SCALEFIT,name="Rough Furrows 0 to 100%. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button4, c4d.BFH_LEFT,50,0)
self.SetPercent(Button4,0.5)
self.AddStaticText(ButtonInfo5, c4d.BFH_SCALEFIT,name="Fine Furrows 0 to 100%. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button5, c4d.BFH_LEFT,50,0)
self.SetPercent(Button5,0.5)
self.AddStaticText(ButtonInfo6, c4d.BFH_SCALEFIT,name="Scale. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button6, c4d.BFH_LEFT,50,0)
self.SetReal(Button6,1)
self.AddStaticText(ButtonInfo7, c4d.BFH_SCALEFIT,name="Sea Level. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button7, c4d.BFH_LEFT,50,0)
self.SetPercent(Button7,0)
self.AddStaticText(ButtonInfo8, c4d.BFH_SCALEFIT,name="Plateau Level. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button8, c4d.BFH_LEFT,50,0)
self.SetPercent(Button8,1)
self.AddStaticText(ButtonInfo9, c4d.BFH_SCALEFIT,name="Multifractal. ",borderstyle=c4d.BORDER_NONE )
self. AddCheckbox(Button9, c4d.BFH_LEFT,20,20,"")
self.SetBool(Button9, 1)
self.AddStaticText(ButtonInfo10, c4d.BFH_SCALEFIT,name="Seed. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button10, c4d.BFH_LEFT,50,0)
self.SetReal(Button10,2)
self.AddStaticText(ButtonInfo11, c4d.BFH_SCALEFIT,name="Boarders At Sea Level. ",borderstyle=c4d.BORDER_NONE )
self. AddCheckbox(Button11, c4d.BFH_LEFT,20,20,"")
self.SetBool(Button11,1)
self.AddStaticText(ButtonInfo12, c4d.BFH_SCALEFIT,name="Number of Objects in Scene. ",borderstyle=c4d.BORDER_NONE )
self.AddEditNumberArrows(Button12, c4d.BFH_LEFT,60,0)
self.SetLong(Button12,100)
self.count=0
self.LayoutChanged(10092) #Updates the custom gizmo changes made to the GUI
self.GroupEnd()
return True
def Command(self, id, msg) :
#Setting min max entries of buttons
if self. GetLong(Button2)>1000:
self.SetLong(Button2,1000)
if self. GetLong(Button2)<1:
self.SetLong(Button2,1)
if self. GetLong(Button3)>1000:
self.SetLong(Button3,1000)
if self. GetLong(Button3)<1:
self.SetLong(Button3,1)
if self. GetReal(Button4)>1:
self.SetPercent(Button4,1)
if self. GetReal(Button4)<0:
self.SetPercent(Button4,0)
if self. GetReal(Button5)>1:
self.SetPercent(Button5,1)
if self. GetReal(Button5)<0:
self.SetPercent(Button5,0)
if self. GetLong(Button6)>10:
self.SetLong(Button6,10)
if self. GetLong(Button6)<1:
self.SetLong(Button6,1)
if self. GetReal(Button7)>1:
self.SetPercent(Button7,1)
if self. GetReal(Button7)<0:
self.SetPercent(Button7,0)
if self. GetReal(Button8)>1:
self.SetPercent(Button8,1)
if self. GetReal(Button8)<0:
self.SetPercent(Button8,0)
if self. GetLong(Button10)>1000:
self.SetLong(Button10,1000)
if self. GetLong(Button10)<0:
self.SetLong(Button10,0)
if self. GetReal(Button_X_Vector)>1000:
self.SetReal(Button_X_Vector,1000)
if self. GetReal(Button_X_Vector)<1:
self.SetReal(Button_X_Vector,1)
if self. GetLong(Button12)>100000:
self.SetLong(Button12,100000)
if self. GetLong(Button12)<10:
self.SetLong(Button12,10)
if id == Button1:
print" Button Pushed"
doc = c4d.documents.GetActiveDocument()
selected = doc.GetObjects()
if len(selected) > 0: # we have one or more selected objects in the scene
for ob in selected:
if ob.GetName() == "Ecco Landscape":
print "Yeeehaaaw"
ob.Remove()
else:
print "Drat"
ob.DelBit(c4d.BIT_ACTIVE)
if ob.GetName() == "Ecco Landscape Object":
ob.Remove()
Container = c4d.BaseObject(5140) # Null
doc.InsertObject(Container)
Container.SetName("Ecco Landscape" )
c4d.EventAdd()#Updates the custom gizmo changes made to the GUI
InstanceContainer = c4d.BaseObject(5140) # Null
doc.InsertObject(InstanceContainer,Container)
InstanceContainer.SetName("Instance Container" )
c4d.EventAdd()#Updates the custom gizmo changes made to the GUI
Landscape = c4d.BaseObject(5169) # Landscape
doc.InsertObject(Landscape,Container)
Landscape.SetName("Ecco Landscape Object" )
c4d.EventAdd()#Updates the custom gizmo changes made to the GUI
Landscape.SetBit(c4d.BIT_ACTIVE)
#Insurts values for buttons into landscape object
Landscape()[c4d.PRIM_FRACTAL_SUBW]=self. GetLong(Button2)
Landscape()[c4d.PRIM_FRACTAL_SUBH]=self. GetLong(Button3)
Landscape()[c4d.PRIM_FRACTAL_ROUGH]=self. GetReal(Button4)
Landscape()[c4d.PRIM_FRACTAL_FINE]=self. GetReal(Button5)
Landscape()[c4d.PRIM_FRACTAL_SCALE]=self. GetReal(Button6)
Landscape()[c4d.PRIM_FRACTAL_BLEVEL]=self. GetReal(Button7)
Landscape()[c4d.PRIM_FRACTAL_TLEVEL]=self. GetReal(Button8)
Landscape()[c4d.PRIM_FRACTAL_MULTIFRACTAL]=self. GetBool(Button9)
Landscape()[c4d.PRIM_FRACTAL_SEED]=self. GetLong(Button10)
Landscape()[c4d.PRIM_FRACTAL_BORDERS]=self. GetBool(Button11)
Landscape()[c4d.PRIM_FRACTAL_LEN]=self.GetVector(Button_X_Vector,Button_Y_Vector,Button_Z_Vector)
c4d.CallCommand(12236) # Make Editable
Poygon_X_Width = self. GetReal(Button_X_Vector)/self. GetLong(Button2)
Poygon_Z_Width = self. GetReal(Button_Z_Vector)/self. GetLong(Button3)
PointCountOfMesh = (self. GetReal(Button_X_Vector+1))*(self. GetReal(Button_Z_Vector+1))-(self. GetReal(Button_X_Vector+1))
for con in range(self. GetLong(Button12)) :
random.seed(con+self. GetReal(Button10))
PointPosInstance = long(random.random()*con)
PointPosInstance_x = (random.random()*Poygon_X_Width)
PointPosInstance_z = (random.random()*Poygon_Z_Width)
print PointPosInstance
print PointPosInstance_x
print PointPosInstance_z
p1=PointPosInstance
p2=p1+1
p3=p1+self. GetLong(Button2)+1
p4=p3+1
cg = Landscape.GetPoint(10) #error here<------------------------------------
Instance = c4d.BaseObject(5126) # Instance
doc.InsertObject(Instance,InstanceContainer)
Instance.SetName(" Instance"+ "_" + str(con ))
c4d.EventAdd()#Updates the custom gizmo changes made to the GUI
EndLineCount=1
c4d.EventAdd()#Updates the custom gizmo changes made to the GUI
return True
#---------------------------------------------------------------
# MyDialog_Main --- Where the plugin stuff happens--Don't edit
#---------------------------------------------------------------
class myDialog_Main(plugins.CommandData) :
dialog = None
def Execute(self, doc) :
# create the dialog
if self.dialog is None:
self.dialog = MyDialog_Gui()
return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=Plugin_ID, defaultw=250, defaulth=550, xpos=-1, ypos=-1)
def RestoreLayout(self, sec_ref) :
# manage nonmodal dialog
if self.dialog is None:
self.dialog = MyDialog_Gui()
return self.dialog.Restore(pluginid=Plugin_ID, secret=sec_ref)
if __name__ == "__main__":
path, fn = os.path.split(__file__)
bmp = bitmaps.BaseBitmap()
bmp.InitWith(os.path.join(path, "res/icons/", "None"))
plugins.RegisterCommandPlugin(Plugin_ID, "EccoLandScapeGenerator",0,None,"", myDialog_Main())