qtvismach, a axis toolpath
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7769
- Thank you received: 2053
06 Dec 2024 21:47 #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.
You need to define the pin:
c.newpin("flipcolor", hal.HAL_BIT, hal.HAL_IN)
then instead of using Color use HALColor:
I added the modified fanuc_200f.py file too for clarity.
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:
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.
The following user(s) said Thank You: tommylight, MarkoPolo
Please Log in or Create an account to join the conversation.
- MarkoPolo
- Offline
- Elite Member
Less
More
- Posts: 260
- Thank you received: 71
06 Dec 2024 23:50 #316142
by MarkoPolo
Replied by MarkoPolo on topic qtvismach, a axis toolpath
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?
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?
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7769
- Thank you received: 2053
07 Dec 2024 04:10 #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:
c.newpin("color", hal.HAL_U32, hal.HAL_IN)
link7 = HALColor([link7], c, "color",alpha=0.5)
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 or Create an account to join the conversation.
- Aciera
- Offline
- Administrator
Less
More
- Posts: 3946
- Thank you received: 1705
07 Dec 2024 08:51 #316169
by Aciera
Have a look at how the tool cylinder is created and updated.
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 or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7769
- Thank you received: 2053
07 Dec 2024 23:31 #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.
I added them to the docs too.
The following user(s) said Thank You: tommylight, MarkoPolo
Please Log in or Create an account to join the conversation.
- MarkoPolo
- Offline
- Elite Member
Less
More
- Posts: 260
- Thank you received: 71
07 Dec 2024 23:48 #316222
by MarkoPolo
Replied by MarkoPolo on topic qtvismach, a axis toolpath
The improved color control is nice, but I haven't been able to get the material resizing to work yet.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7769
- Thank you received: 2053
08 Dec 2024 01:23 #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?
These change the shape of an object.
Can you post the material object building code?
Please Log in or Create an account to join the conversation.
- MarkoPolo
- Offline
- Elite Member
Less
More
- Posts: 260
- Thank you received: 71
08 Dec 2024 11:36 #316239
by MarkoPolo
Replied by MarkoPolo on topic qtvismach, a axis toolpath
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
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 or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7769
- Thank you received: 2053
09 Dec 2024 04:26 #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
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
The following user(s) said Thank You: MarkoPolo
Please Log in or Create an account to join the conversation.
- MarkoPolo
- Offline
- Elite Member
Less
More
- Posts: 260
- Thank you received: 71
09 Dec 2024 13:15 #316331
by MarkoPolo
Replied by MarkoPolo on topic qtvismach, a axis toolpath
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..
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 or Create an account to join the conversation.
Moderators: cmorley
Time to create page: 0.079 seconds