Comments (6)
Okay, i found it. I didnt check the addon menu properly :)
This is really well done man! Im working on some addons and was always wondering how people make the custom UI items in the 3dview port. Is it okay i look at how you did that?
from archipack.
Hi,
Feel free to inspire, re-use the way you like !
Archipack's sample may be overkill, as it does override regular preset_loader operator and hide bgl logic behind an abstraction layer.
archipack_presets.py and archipack_gl.py
You may take a look at asset flinger implementation (wich was inspiration for archipack preset menu).
Asset flinger github repo
As a side note, bgl module is currently not supported in 2.8 series and a complete rewrite is planed, so this api is likely to change.
Also keep in mind that some folders are read only - this is the main reason for your issue, presets have to move into user profile folder to be writeable.
from archipack.
Aha, thanks for explaining! Im helping a guy with a addon for Thea Render engine and have done many adds for this render engine. What i like i that GUI in the 3dview when something is added, just like HardOps has. This makes it much more clear that something is happening. At the moment when we render in the view port, there is only simple text which can be set to a certain size. I would like to make this a bit more visible if i can do so.
I also like those foldout menu's, I wanted to use those small + menu but not really got how that worked. This is done much easier using a simple boolean and if else statement.
I do see something about BGL in API 2.78 https://docs.blender.org/api/blender_python_api_current/bgl.html
I will see if i can understand all of that. What ive seen so far is that there are tons of functions involved to show something on top of blender GUI in viewport.
from archipack.
Yep, drawing using gl is painfull, but archipack provide an abstraction layer to do so.
see Feedback panel
The feedback panel does rely on archipack addon preferences for colors and font sizes (parameters are in init.py).
from archipack.
I did look into it and got some simple square. Not sure how you manage to have the rectangle below the text. I did also have this with mine, but when its rendering the text stays and the rectangle becomes darker and darker.
Do you draw the whole block as a new image or something?
Finding the code in the files took me a while as well as to figure it all out. I think i should start with a very simple square, than add more dynamic aspects and more interaction if needed.
from archipack.
Hi,
Feedback panel and Preset menu are full real-time gl only.
Obviously i'm using images in thumbs, but that's it.
From what you say it seem you are adding the draw handler more than once.
I can't figure if you try to use FeedbackPanel or Preset menu ?
Could you share the code ?
Here is a complete sample of proper Feedback usage in a modal.
import bpy
from bpy.types import Operator
from .archipack_gl import FeedbackPanel
class DEMO_OP_Feedback(Operator):
bl_idname = "demo.feedback"
bl_label = "Feedback"
bl_description = "Feedback panel in modal"
bl_options = {'REGISTER', 'UNDO'}
feedback = None
_handle = None
# draw callback
def draw_callback(self, _self, context):
self.feedback.draw(context)
def invoke(self, context, event):
# Create a panel instance
self.feedback = FeedbackPanel(title="Main Title")
self.feedback.instructions(context, "Sub title", "hint", [
('SHIFT', 'deselect'),
('CTRL', 'contains'),
('A', 'All'),
('I', 'Inverse'),
('ESC or RIGHTMOUSE', 'exit when done')
])
# Enable panel
self.feedback.enable()
# panel draw handler to be added only once at beginning
args = (self, context)
self._handle = bpy.types.SpaceView3D.draw_handler_add(
self.draw_callback,
args,
'WINDOW',
'POST_PIXEL')
# add modal handler
context.window_manager.modal_handler_add(self)
return {'RUNNING_MODAL'}
def modal(self, context, event):
# tag area for gl redraw
context.area.tag_redraw()
# exit condition
if event.type in {'ESC', 'RIGHTMOUSE'}:
# Ensure you remove your draw handler on exit
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
self.feedback.disable()
return {'FINISHED'}
# do whatever you need
if user_do_something:
# here you are able to change feedback on the fly, calling instructions again
self.feedback.instructions(context, 'Title', 'Hints about usage', [
('SHORTCUT', 'Hints about shortcut'),
...
])
if no_feeddback_need_for_this_action:
# disable / enable feedback drawing at any time too
self.feedback.disable()
return {'RUNNING_MODAL'}
from archipack.
Related Issues (20)
- Errors archipack 1.3.8 community edition not compatible with blender 4.0 HOT 2
- Traceback error in Blender 4.0.2 on Windows 11 (archpack_2.0.9) HOT 4
- Python error colorspace "Raw" not found HOT 1
- Fontsize too small HOT 1
- Issue installing Archipack 1.38 on Blender 3.1.2 HOT 1
- Archpack Installation error HOT 1
- Convert walls not working HOT 1
- Archipack Pro Error on Enabling (Blender 4.0 / Windows) HOT 1
- installation fails with blender 4.1 HOT 2
- onstallation fails with blender 4.0 HOT 1
- error when activating add-on macOS HOT 1
- Pease Help me Fix this Issue as soon as posible HOT 1
- Wrong Boolean assignment with floors and assemblies HOT 3
- Can't Install Blender 4.1.1 HOT 5
- activation impossible archipack pro HOT 1
- Can not install Archipack HOT 1
- Can not activate HOT 1
- Archipack 1.2.x "community edition" not compatible with blender 4.x HOT 1
- Archipack 2.4 not working on blender 4.0.1 HOT 3
- Custom door presets not being saved. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from archipack.