- Posts: 7368
- Thank you received: 2181
qtvismach, a axis toolpath
- cmorley
- Offline
- Moderator
-
Less
More
2 years 7 months ago #295797
by cmorley
Replied by cmorley on topic qtvismach, a axis toolpath
You can get them from STATUS, as long as the preview window is in the same python context.
Meaning you would need to have the vismach window embedded in, or loaded from, qtdragon.
The normal qtvcp embedding should work, getting a separate window is custom work.
then:
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
would give you the raw information in the function update_gcode_properties().
You can see how it was done in qtdragon_handler.py, but something like this:
Meaning you would need to have the vismach window embedded in, or loaded from, qtdragon.
The normal qtvcp embedding should work, getting a separate window is custom work.
then:
STATUS.connect('graphics-gcode-properties', lambda w, d: self.update_gcode_properties(d))
would give you the raw information in the function update_gcode_properties().
You can see how it was done in qtdragon_handler.py, but something like this:
Code:
def update_gcode_properties(self,props):
print(props.get('x'))
print(props.get('y'))
print(props.get('z'))
The following user(s) said Thank You: MarkoPolo
Please Log in or Create an account to join the conversation.
- MarkoPolo
- Online
- Elite Member
-
Less
More
- Posts: 319
- Thank you received: 90
1 year 10 months ago #316134
by MarkoPolo
Replied by MarkoPolo on topic qtvismach, a axis toolpath
That's what you suggested, using STATUS.connect.. I can control the position of the A-axis tailstock.
After reloading the next file, the tailstock is positioned in the appropriate place depending on the dimension of the project in the X axis.
Another thing I want is to re-build the dimensions of the workpiece.
Qt_vismach can update the position of an already built object, but I can't do it to re-build a new workpiece.
I tried adding a new class in primitives.py, analogous to HalTranslate, but it doesn't work.
It would also be interesting to be able to change the colors of some elements, depending on the values of different pins.
How to do it?
After reloading the next file, the tailstock is positioned in the appropriate place depending on the dimension of the project in the X axis.
Another thing I want is to re-build the dimensions of the workpiece.
Qt_vismach can update the position of an already built object, but I can't do it to re-build a new workpiece.
I tried adding a new class in primitives.py, analogous to HalTranslate, but it doesn't work.
It would also be interesting to be able to change the colors of some elements, depending on the values of different pins.
How to do it?
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
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.
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.
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.
The following user(s) said Thank You: tommylight, MarkoPolo
Please Log in or Create an account to join the conversation.
- MarkoPolo
- Online
- Elite Member
-
Less
More
- Posts: 319
- Thank you received: 90
1 year 10 months ago #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: 7368
- Thank you received: 2181
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:
c.newpin("color", hal.HAL_U32, hal.HAL_IN)
link7 = HALColor([link7], c, "color",alpha=0.5)
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 or Create an account to join the conversation.
- Aciera
- Offline
- Administrator
-
Less
More
- Posts: 4819
- Thank you received: 2177
1 year 10 months ago #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.
Moderators: cmorley
Time to create page: 0.154 seconds