draw and properties visibility !

I made a class for and add mesh menu

and added a checkbox conditions like this

if checkweight: # Z Linear ht

ht=phi
print (‘check True ht=’,ht )
strc=str(‘ht = phi’.format(ht))
layout.label(str(strc))

else:

ht= self.properties.ht

strc=str(‘ht’.format(ht))
layout.label(str(strc))
print (‘check False ht=’,ht)

so if checkbox is false it should add the property
but if I set the checkbox the property remain visible

like panel is not update
is this normal or another way to add or remove a property from the panel?

how do you passes var between the draw part and the execute part ?
global vars ?

thanks

Just don’t display the label or property in the else case.

in one case I use a fix value = phi
but in the other case I need a var = property

are you saying it is not possible to do that with panel update !

trying to work with class var now
and almost doing it but not updating as it should!

how do u passes var between functions in panel?
need to use class vars !

thanks

how do u passes var between functions in panel?

I just store my vars in the object as custom property. Then when I need them I already know I am self and can fetch them.

Here is what I typically put at the top of my draw.

def draw(self, context):
    if context != None:
        ob = context.object
        if ob != None:

myvar = ob.[“myvar”]

Assuming this is an object based panel, of course. This technique can work with any datablock that supports custom properties though. Like materials etc…

got to review these class and local vars!
don’t use that often

I know you can add prop or not in a panel
but for this operator not certain if it is possible!

I can make small file for the prop
let me know if that can help

thanks

You can pass the calling name along to the operator. Then the operator can be coded to fetch the variable from the calling object’s properties.

can you run this



###
	
class Goldenspiralzphi1(bpy.types.Operator):
	
	'''Add Golden spiral zphi1'''
	
	bl_idname = "mesh.primitive_goldenspiralzphi_add"
	bl_label = "Add Golden Spiral"
	bl_options = {'REGISTER', 'UNDO','BLOCKING'}
	
	seg1 = IntProperty(name="Segments", description="Number  segments",default=32, min=4, max=100)
	nturn = FloatProperty(name="nturn", description="nturn",default=1, min=1, max=100.0)
	ht= FloatProperty(name="Height/turn",description="Height/turn", default=1.2, min=0.0, max=100.0)
	a1 = FloatProperty(name="a1",description="a1",default=0.05, min=0.001, max=100.0)
	curveadd=BoolProperty(name='add curve bevel',default=False,description='add curve bevel')
	
	checkweight = bpy.props.BoolProperty(name='Use Z=F(PHI)',default=False,description='Use Z=F(PHI)')
	
	var1=1.6180339
	
	def draw(self, context):						# Function to draw the menu in tool pro panel
	
		seg1 = self.properties.seg1
		checkweight= self.properties.checkweight
		a1 = self.properties.a1
		nturn = self.properties.nturn
	
		curveadd= self.properties.curveadd
	
		layout = self.layout
	
		if checkweight:				# Z = F( PHI )
	
	
			ht= self.properties.ht
			Goldenspiralzphi1.var1=ht
	
			print ('check  True  ht=',ht )
			strc=str('ht = phi'.format(ht))
			layout.label(str(strc))
	
		else:						# Z Linear  ht
	
			ht=phi
			Goldenspiralzphi1.var1=phi
			
			strc=str('ht'.format(ht))
			layout.label(str(strc))
			print ('check  False  ht=',ht)
	
		print ( 'class var =',Goldenspiralzphi1.var1)
	
#		layout.prop(self, "checkweight", text = "Z =F(PHI)")
		layout.prop(self, "checkweight", text = strc)
	
		layout.prop(self, "seg1", text = "seg1")
		layout.prop(self, "a1", text = "a1")
		layout.prop(self, "nturn", text = "nturn")
		layout.prop(self, "ht", text = "ht")
		layout.prop(self, "curveadd", text = "curveadd")
	
	
	
	def execute(self, context):
	
		global  layers
		verts,edges,faces,vid= [],[],[],0
		bm = bmesh.new()									# Create new Bmesh mesh
		named1="Golden Spiralzphi1"
	
	
		seg1 = self.properties.seg1
		checkweight= self.properties.checkweight
		a1 = self.properties.a1
		nturn = self.properties.nturn
		ht= self.properties.ht
	
		curveadd= self.properties.curveadd
	
		ht1=Goldenspiralzphi1.var1
		print ('ht1=',ht1)
	
	#   R =  G^(2 Theta / pi )	
	#   R = a1  exp(b1 * phi)	 b1 = a bs(log(phi)/90)
	#   R = a1* exp(b1 * n) 
	
		phi=(1.0+5.0**0.5)/2.0				# golden ratio ~ 1.618
		b1=abs(log(phi)/90.0)
		b2=log(2)
	
		minag,maxag=0,nturn*360
	
		step1=(maxag-minag)/(seg1*nturn)
	
		for n1 in float2_range(minag, maxag, 1):
	
			ANGTR=n1*pi/180
			ro= a1* exp(b1* n1)
			XC=ro*cos(ANGTR)
			YC=ro*sin(ANGTR)
			ZC=ANGTR*ht1/(2*pi)
	
			verts.append(bm.verts.new((XC,YC,ZC)))			# Add vertices
	
			if vid > 0:										# Add edges
				edges.append(bm.edges.new((bm.verts[vid-1], bm.verts[vid])))
			vid+= 1
	
		adddata1(bm,named1,verts,curveadd)

	
		return {'FINISHED'}
	
###



it works if you click on checkbox a few times
but not the first time

thanks

There are too many bugs in that script, it does not even run once. Try pasting that code into a script window and you will see what I mean.