ZBrushCentral

successive ZSphereAdd/Set problem.

Hi, Marcus,
Looking at the list of questions lately on this forum I’m growing into a big-appetite-user on the forum. I don’t hope this is too much for you?
But… I’m having some additional problems while making a new plugin. I see my questioning as a neccessairy phase in my learning process, especially because ZB doesn’t give a real reference guide with many different examples. So that’s my argument to bother you again.

The problem:
I want to be able to place a row of ZSpheres with a zscript starting from ZSphere0
and then ZSphere1 at horizontal distance +50 from parent ZSPhere0
and then ZSphere2 at horizontal distance +50 from parent ZSPhere1
and then ZSphere3 at horizontal distance +50 from parent ZSPhere2
all with the same radius=20
I use as code something like hereunder.

  1. As you will notice in the code the 2th and 3th ZSphere do fail to come on the right spot, even the radius seems to become bigger than the ordered 20, more like 40 (as if a newly drawn one)
  2. ZB seems to have a problem with using the variable radius in [ZSphereSet, 4,2,radius]
  3. I tried to integrate in my code the example I found somewhere on the forum to translate Canvas to Globalvalues. They suggest the formula:
    [varset,gx1,gx+50][varset,gy1,gy][varset,gz1,gz]
    [varset,nx,(gx1-gx)*0.01]
    [varset,ny,(gy1-gy)*0.01]
    [varset,nz,(gz1-gz)*0.01]
    However, when I do this I can’t see any new ZSphere on screen; I also do not understand the reasoning behind this ‘*0.01’

Code:

[RoutineDef,R_MultipleZSpheres,
[varset,cancenhor,(Document:Width*.5)]
[varset,cancenvert,(Document:Height*.5)]
[Transformset,cancenhor,cancenvert,0,100,100,100,0,0,0]
[FileNameSetNext,“ZBRUSH_ZStartup\ZPlugs\NewGeoExtrudeTemp\workmesh.ztl”]
[IPress,Tool:Save As]
[IPress,Tool:Clone]//workmesh#1
[IPress,Tool:ZSphere]
[IPress,Tool:Clone]//zsphere#1
[Transformset,cancenhor,cancenvert,0,100,100,100,0,0,0]
[ZSphereEdit,
[ZSphereSet,4,0,20]//Sets the radius of the 0th zsphere to 20
]

[Transformset,cancenhor,cancenvert,0,100,100,100,0,0,0]
[varset,gx,cancenhor][varset,gy,cancenvert][varset,gz,0]
//1th additional zsphere:
[varset,gx1,gx+50][varset,gy1,gy][varset,gz1,gz]
[varset,nx,(gx1-gx)]
[varset,ny,(gy1-gy)]
[varset,nz,(gz1-gz)]
[ZSphereEdit,
[ZSphereAdd,nx,ny,nz,20,0] //adds ZSphere1 at +50 offset from x-zsphere_0 and radius=20

FROM HEREON ZB DOESN’T PERFORM LIKE I EXPECT:

[Transformset,cancenhor,cancenvert,0,100,100,100,0,0,0]
//2 additional zsphere:
[varset,gx1,gx+100][varset,gy1,gy][varset,gz1,gz]
[varset,nx,(gx1-gx)]
[varset,ny,(gy1-gy)]
[varset,nz,(gz1-gz)]
[IPress,Tool:ZSphere] //I don’t think this to be necessary
[ZSphereEdit,
[ZSphereAdd,nx,ny,nz,20,1]//Should add ZSphere2 at +100 offset from x-zsphere_0 and radius=20; instead creates a much larger sphere that seems to be at 0,0,0, like a new zero-ZSphere!!!
]
//Now I try to change the radius with a variable, just to try:
[ZSphereEdit,
[ZSphereGet,4,2,radius]
[ZSphereSet,4,2,radius+10]
//ZB Gives INPUT-ERROR, because I use a variable iso a constant?
]

[Transformset,cancenhor,cancenvert,0,100,100,100,0,0,0]
//3
[varset,gx1,gx+150][varset,gy1,gy][varset,gz1,gz]
[varset,nx,(gx1-gx)]
[varset,ny,(gy1-gy)]
[varset,nz,(gz1-gz)]
[IPress,Tool:ZSphere]
[ZSphereEdit,
[ZSphereAdd,nx,ny,nz,20,2]
/*should add ZSphere3 at +150 offset from x-zsphere_0 and radius=20; instead probably also creates a much larger sphere that seems to be at 0,0,0, like a new zero-ZSphere!!!
I can’t see that on the screen, because the strange placing of ZShere2 */
]
[exit]
]

  1. Another problem is that I want to be able to simulate a series of LBM-clicks on specific points from each other (for instance: 10 points south from each other, starting at a given canvaspoint, say horizontal 100, vertical 200)
    I want to use this for a variation of the above.

The idea is to create a kind of spine of ZSpheres that can be curved and bend after ‘Tool:Rigging:Bind Mesh’.
In a variation of the same idea I need the canvas-clicks for the creation of miniZSpheres, using ‘Tool:Topology:Edit Topology’, the method published in july (?) by Rastaman.

Well, Marcus, I hope you will be willing and able to help me with this learningstep, so I can post another plugin under the name of ‘EasyCurve’ or something like that. I wil also use the code as an upgrde of NewGeoExtrude.

Greetings, EddyL

Hi Eddy,

Perhaps we should have a new forum just for your questions. :wink:

  1. With this, I’m afraid there is a big problem: the ZSphere editing commands do not work as they should. When setting the position or radius, for any value over 16, the value is set at 16. This means that the commands are not very useful. :frowning:

I had fun with a workaround (but this isn’t very useful either!):

[IButton,ZSphereChain,"Creates a chain of zspheres",
	[IPress,Tool:ZSphere]
	[CanvasClick,(document:width/2),(document:height/2),(document:width/2),(document:height/2)+100]
	[IPress,Transform:Edit]
	[VarSet,total,4]//total zspheres in chain
	[VarSet,target,50]//final radius
	[VarSet,radius,1]//starting radius
	[VarSet,index,1]//starting spacing
	//*** (index*total) must be <=16 ***
	//*** (target*index)/radius = space between zspheres ***
	[VarSet,add,#index]
	[ZSphereEdit,
		[ZSphereSet,4,0,radius]
	,1]
		[Loop,total-1,
			[ZSphereEdit,	
			[ZSphereAdd,index,0,0,radius,index]	
			,1]
			[VarAdd,index,add]
		]	
	[Loop,20,
		[ISet,Tool:Deformation:Size,100]
		[ZSphereEdit,
			[VarSet,radius,[ZSphereGet,4,0]]
		,1]
		[If,#radius >= (#target/2),
			[ISet,Tool:Deformation:Size,((target/radius)-1)*100]
			[LoopExit]
		]
	]
	[IPress,Transform:Move Edit]	
]
  1. Radius variable problem:
[ZSphereEdit,
[ZSphereGet,4,2,radius]
[ZSphereSet,4,2,radius+10]
//ZB Gives INPUT-ERROR, because I use a variable iso a constant?
]

The problem here is that the syntax is wrong. You can’t assign a value to a variable within the ZSphereGet command. This should work:

[ZSphereEdit,
[VarSet,radius,[ZSphereGet,4,2]]
[ZSphereSet,4,2,radius+10]
]
  1. Global values:
    I’ve no idea to what you are referring to here. If the method was for ZBrush 2 or earlier it is quite likely that it won’t work for ZBrush 3. Many things have changed.

  2. Simulating mouse clicks:

It is possible to simulate mouse clicks on the canvas by using the [CanvasClick] command, specifying coordinates for the first click and further coordinates for a drag. I’ve no idea whether this would work for what you are trying to do.

HTH,

Hi Marcus,

Thanks for your quick and helping comments. I get your workaround and understand also why it doesn’t work, but It helped me to try out some other route and I found it!
I’ll show the workaround in my next plugin: NewGeoExtrudeAndCurve.
It’s really working quite nice, but I use a slider to move/deformation some help-objects to get information about the Base and the Endponts on the mesh from which and to which the curve’spine’ must go.

That is working allright but remains somewhat clumsy.
So I thought of an other approach with:

[Note, “Now LMB-click naer the Base of the ‘curve-area’ of the mesh”,1]
[Loop,10000,
[If,([MouseLButton==1]),
[varset,endpoint,[MouseHPos]]
[messageOK,“endpoint found”]
[LoopExit]
]//endif
]//endloop
This should work? But it doesn’t do the trick. the [messageOK,“endpoint found”] is not executed!
What oh what am I doing wrong?

Greetings, EddyL

Eddy,

It’s just that the loop will execute too quickly, even with 10000 iterations. The solution is to put in a delay:


[Loop,10000,
[Delay,.001]
[If,([MouseLButton]==1),
[varset,endpoint,[MouseHPos]]
[messageOK, "endpoint found"]
[LoopExit]
]//endif
]//endloop