qtvismach, a axis toolpath

More
1 year 10 months ago #316140 by cmorley
Replied by cmorley on topic qtvismach, a axis toolpath
The color change pin was pretty easy. This shows an example how to have a pin that flips between two preset colors.
Code:
class HALColor(Collection):     def __init__(self, color1, color2, parts, comp, var):         self.color1 = color1         self.color2 = color2         self.comp = comp         self.var = var         Collection.__init__(self, parts)     def apply(self):         try:             if self.comp is None:                 v = hal.get_value(self.var)             else:                 v = self.comp[self.var]         except:             v = 0         if v : c = self.color1         else: c = self.color2         GL.glPushAttrib(GL.GL_LIGHTING_BIT)         GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, c)     def unapply(self):         GL.glPopAttrib()

You need to define the pin:

c.newpin("flipcolor", hal.HAL_BIT, hal.HAL_IN)

then instead of using Color use HALColor:
Code:
link7 = HALColor([0.1,0.1,0.1,1], [1,1,0,1], [link7], c, "flipcolor",)

I added the modified fanuc_200f.py file too for clarity.
 

Please Log in to join the conversation.

More
1 year 10 months ago #316142 by MarkoPolo
Great, it works.

It works when I run it as a built-in window in qtdragon.

I also run the simulation in a standalone window, because
in a built-in window, the toolpath is drawn only if the window is active.
In a separate window, the path is always drawn.
When I run it in a separate window, there is a problem with the hal component and adding the pin.
Maybe add the flipcolor pin in the main hal file, or something else?

Please Log in to join the conversation.

More
1 year 10 months ago #316156 by cmorley
Replied by cmorley on topic qtvismach, a axis toolpath
Uses a HAL U32 pin to set the color.  Alpha can be preset:
Code:
class HALColor(Collection):     def __init__(self, parts, comp, var, alpha=1.0):         self.comp = comp         self.var = var         self.alpha = float(alpha)         Collection.__init__(self, parts)     def apply(self):         try:             if self.comp is None:                 v = hal.get_value(self.var)             else:                 v = self.comp[self.var]         except:             v = 0         r = ((v & 0x000000FF) >> 0)/255         g = ((v & 0x0000FF00) >> 8)/255         b = ((v & 0x00FF0000) >> 16)/255         c =[r,g,b,self.alpha]         GL.glPushAttrib(GL.GL_LIGHTING_BIT)         GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, c)         GL.glEnable(GL.GL_BLEND)         GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)     def unapply(self):         GL.glPopAttrib()         GL.glDisable(GL.GL_BLEND)

c.newpin("color", hal.HAL_U32, hal.HAL_IN)

link7 = HALColor([link7], c, "color",alpha=0.5)

 

Please Log in to join the conversation.

More
1 year 10 months ago #316169 by Aciera
Replied by Aciera on topic qtvismach, a axis toolpath

Another thing I want is to re-build the dimensions of the workpiece.


Have a look at how the tool cylinder is created and updated.

Please Log in to join the conversation.

More
1 year 10 months ago #316219 by cmorley
Replied by cmorley on topic qtvismach, a axis toolpath
I pushed HALColorRGB and HALColorFlip functions to master.
I added them to the docs too.

Please Log in to join the conversation.

More
1 year 10 months ago #316222 by MarkoPolo
The improved color control is nice, but I haven't been able to get the material resizing to work yet.

Please Log in to join the conversation.

More
1 year 10 months ago #316229 by cmorley
Replied by cmorley on topic qtvismach, a axis toolpath
Have you looked at HalToolCylinder and HalToolTriangle ?
These change the shape of an object.

Can you post the material object building code?

Please Log in to join the conversation.

More
1 year 10 months ago #316239 by MarkoPolo
length = hal.get_value("hor_pos")
length = (float(length) + 115)
mat = Box(60, -30, -30, length, 30, 30)
mat = Color([0.4, 0.6, 0.2, 0.4],[mat])
mat = Rotate([mat],0,45,0,0)
mat = Translate([mat],0,0,0)
mat = Color([1, 1, 0, 1],[mat])

This is how I build a material element mounted in a lathe.

For now, only the material length is determined automatically, depending on the position of the lathe tailstock.

After the first simulation run, the material dimensions are drawn correctly. The problem is with rebuilding the dimension after running another ngc file with different dimensions.

I tried using HalToolCylinder and HalToolTriangle in various ways, but I must be doing something wrong

Please Log in to join the conversation.

More
1 year 10 months ago #316303 by cmorley
Replied by cmorley on topic qtvismach, a axis toolpath
If you create a component (called comp, with a float pin named length) in your script, you can use this for the box:

Box(comp, 60, -30, -30, 'length', 30, 30)

or with no component in the script this should work:
Box(60, -30, -30, 'comp_name.length', 30, 30)

All the other entries can use a string to force evaluation of a HAL pin too.

Chris

Please Log in to join the conversation.

More
1 year 10 months ago #316331 by MarkoPolo
Perfect, it works this way. thanks

By the way, I propose a small change in qt_vaismach.py
in the zooIn and zoomout functions add and subtract the value of self.near.

Now, with a big zoom, you have to really turn the mouse wheel to fully zoom in and then zoom out.

After such a change, it is much more pleasant, more linear operation.

Such a correction would also be useful in the main preview window, but I haven't found a solution for this..

Please Log in to join the conversation.

Time to create page: 0.125 seconds
Powered by Kunena Forum