No Attributes
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 11:06, xxxxxxxx wrote:
Hi all im a newby here and to python i have a problem with this line of script.
cg = Landscape.GetPoint()
Its giveing me this error.
AttributeError: c4d.BaseObject object has no attributes GetPoint.
Can you give me an isite to why this cheers.
Ray. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 11:11, xxxxxxxx wrote:
Landscape is not a PointObject. Only editable Splines and Polygonobjects provide this function.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 11:24, xxxxxxxx wrote:
Hi the landscape object has been made edible so it does have polygones.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 11:43, xxxxxxxx wrote:
And op.Cache()
-
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,modulesPlugin_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 = 10010Button1 = 100011
Button2 = 100012
Button3 = 100013
Button4 = 100014
Button5 = 100015
Button6 = 100016
Button7 = 100017
Button8 = 100018
Button9 = 100019
Button10 = 100020
Button11 = 100021
Button12 = 100022ButtonInfo1 = 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()) -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 12:14, xxxxxxxx wrote:
Landscape is still a landscape object and not a polygon object. you will either have to grab and drop the created object for each CallCommand or you have to use SendModellingCommand to perform your actions and insert the result afterwards.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 12:20, xxxxxxxx wrote:
i know this is hijacking and i'm sorry, but :
Originally posted by xxxxxxxx
And op.Cache()
where is Cache() located ? i can only find BaseObject.GetCache() and BaseObject.GetDeformCache().
is Cache readonly ? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 12:28, xxxxxxxx wrote:
@Lennart:
c4d.BaseObject.GetCache() does not work while rendering, yet. If you can find a way to get the cache while rendering, I'd really appreciate sharing it.
@t tuuz:Please use the code formatting options the forum provides.
I assume you'd like to have some correction and tips.
-
Your coding style is crap, sorry. Proper indentation and margins as well as a strict naming convention makes reading code more easy. The general convention is to use CamelCase on class-names. In Java, the preferred way to name variables and methods is using mixedCase, and in Python underscore_seperated_names.
-
Starting at Line 244: Calling the object to subscript it is not necessary. Use subscripting directly on the object.
-
Using ResEdit makes life easier when using dialogs.
-
You don't have to call c4d.GeDialog.LayoutChanged() at the end of c4d.GeDialog.CreateLayout()
-
Starting with line 210: You call c4d.EventAdd() multiple times. Don't do that. You won't recognize these changes anyway before the method returned. Only update where necessary, i.e. at the end of the function, and only if things have changed.
-
Line 193: c4d.BaseDocument.GetObjects() does not return the selected objects.
-
Line 207: Use constants defined in the c4d module instead of the constants value directly. "Constants" might change from Cinema 4D Release to Release and your way will make your plugin "release-independant". c4d.Onull is the ID corresponding to a Null-Objec, c4d.Ofractal is the type-constant for the landscape primitve, c4d.Oinstance
-
Line 256: Well, you can use c4d.CallCommand(12236) (note: there are no ids for commands..) and it makes your object editable, but you Landscape variable still refers to the old object. You'd need to get the new object by calling c4d.BaseDocument.GetActiveObject() (after the command, the object that was modified is selected), but that is still very dirty. A better way would be to use c4d.BaseObject.SendModelingCommand() or c4d.GetCache() (as noted above, this method does not work while rendering, but in a script it's fine).
-
Line 357: os.path.join was made for platform independently concatenating paths. You are using a platform dependend partial path which makes using the function quite senseless. os.path.join(path, "res", icons", "None") is the correct way to use it. (Why would you name a file None?)
The point from the ones that answers your question is #8.
@littledevil:
He means c4d.BaseObject.GetCache()
Cheers,
-Niklas -
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 12:44, xxxxxxxx wrote:
Thanks for the reply im only 7 days into writeing python so im picking things up the best way i can in the time ive been doing it so all pointers are welcome cheers.
Ray. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 12:58, xxxxxxxx wrote:
You're doing very well for your 7th day, by the way. You should've seen how I started .. lol
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 14:13, xxxxxxxx wrote:
@ Niklas. GetCache() and GetDeformCache() are read only but works
fine for my renderings (getting info) so I don't know what you mean
that they shouldn't work for rendering?To actually make a polygon object, using SendModelingCommand()
and insert the first index returned would be my recommendation.pointobj = c4d.utils.SendModelingCommand( command = c4d.MCOMMAND_CURRENTSTATETOOBJECT, list = [op.GetClone()], mode = c4d.MODELINGCOMMANDMODE_ALL, doc = doc) newobj = pointobj[0] newobj.InsertAfter(op) c4d.EventAdd()
Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 14:28, xxxxxxxx wrote:
@Lennart:
Sorry, I wasn't clear enough. You can't use GetCache() while rendering in the PictureViewer, i.e. using it on a PythonTag or -Generator does not work.
Create a PythonTag on a Cube and insert that code onto it, hit "Render to PictureViewer" and you'll see that the return of GetCache() is None.
def main() : og = op.GetOrigin() print og, og.GetCache()
Cheers, Niklas
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 15:10, xxxxxxxx wrote:
It works fine here.
Keep in mind that the PictureViewer scans from
first frame up to the frame to be rendered.
So that's when "None" is returned.Try to render at first frame or add a "if".
import c4d def main() : obj = op.GetOrigin() cobj = obj.GetCache() if cobj is not None: print obj, cobj
Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 15:17, xxxxxxxx wrote:
I am confused, once again. It works for me when rendering an animation, but rendering a single frame doesn't.
This is what I get when rendering an animation from Frame 0 to 10, 10 lines, but it should be 11!
<c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A21A0> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596E40> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A2160> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596D60> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A21C0> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596E40> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A21B0> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596D60> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A21A0> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596E40> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A2160> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596D60> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A21C0> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596E40> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A21B0> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596D60> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A21A0> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596E40> <c4d.BaseObject object called 'Cube/Cube' with ID 5159 at 0x0D3A2160> <c4d.PolygonObject object called 'Cube/Polygon' with ID 5100 at 0x0D596D60>
Same when I render from frame 0 to 1, I only get one line but it should be two lines (2 frames actually rendered). I don't get a single line when rendering a single frame.
So the cache isn't available at the first frame? That's senseless actually ..
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 15:30, xxxxxxxx wrote:
Prints the correct pointcount here at frame zero.
import c4d def main() : obj = op.GetOrigin() cobj = obj.GetCache() if cobj is not None: print cobj.GetPointCount()
Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2012 at 15:35, xxxxxxxx wrote:
And to print corresponding frame:
import c4d def main() : obj = op.GetOrigin() cobj = obj.GetCache() if cobj is not None: frame = doc.GetTime().GetFrame(doc.GetFps()) print frame,' <> ',cobj.GetPointCount()
Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2012 at 02:50, xxxxxxxx wrote:
On what C4D Version are you working on? Could you please test this scene? Just open it, clear the console and hit render?
What I get is
<c4d.BaseObject object at 0x07764080> None
Thanks,
-Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2012 at 05:50, xxxxxxxx wrote:
For f** sake Niklas, don't use that linking of yours, I got all sorts of exe and porn install links and pop ups
and no dload.Try to find a safer dload please.
Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2012 at 06:16, xxxxxxxx wrote:
I don't see any of these, Lennart. Sorry. I've uploaded it on my server. tcastudios_cachetest.c4d
-Niklas
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/03/2012 at 06:45, xxxxxxxx wrote:
You need to let the Generator build the cache before the expression,
so set the priority of the tag to "Generators".