Jump to content

Tyronnosaurus

Member
  • Posts

    25
  • Joined

  • Last visited

  • Days Won

    1

Tyronnosaurus last won the day on May 21 2021

Tyronnosaurus had the most liked content!

Personal Information

  • 3D printer
    Other 3D printer

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Tyronnosaurus's Achievements

7

Reputation

  1. To anyone also trying to develop a plugin with 2 views: nallath and I discovered and fixed a small bug in Uranium that caused the previous problems. Since Cura 4.12 beta is already out, I guess the solution is to wait for Cura 4.13 (unless the fix is included in the release version of 4.12). With this fix, Views can be hidden from the dropdown in Preview Stage with the 'visible' metadata as nallath said in the 1st answer.
  2. I can only find one view. Maybe they had 2 in the past but I haven't found anything in past versions. I saw this in Uranium's source code, but still wasn't sure if it was getMetadata() or loadPlugin() that was doing the calling, and how was plugin_id generated in _populateMetaData(self, plugin_id: str). In any case, I've found something that may be a possible bug: I managed to run Cura from source, and added some code in Uranium to see all the stack of function calls when _populateMetaData() is called, from deepest to highest: 'C:\dev\Uranium\UM\PluginRegistry.py', L776, _populateMetaData() 'C:\dev\Uranium\UM\PluginRegistry.py', L273, getMetaData() 'C:\dev\Uranium\UM\Qt\Bindings\ViewModel.py', L41, _update() 'C:\dev\Uranium\UM\Signal.py', L332, __performEmit() 'C:\dev\Uranium\UM\Signal.py', L219, emit() 'C:\dev\Uranium\UM\Controller.py', L118, setActiveView() 'C:\dev\Uranium\UM\Qt\Bindings\ControllerProxy.py', L41, setActiveView() 'C:\dev\Uranium\UM\Qt\Bindings\ControllerProxy.py', L116, _onActiveStageChanged() etc The 3rd deepest function is ViewModel.update(). Note how it only accounts for Views that have been automatically assigned the same name as the plugin. If a view is named as PluginName_ViewName, it will not be found because there's no such plugin by that name: views = self._controller.getAllViews() ... for view_id in views: view_meta_data = PluginRegistry.getInstance().getMetaData(view_id).get("view", {}) Edit: if I change it like this, everything works: views = self._controller.getAllViews() ... for view_id in views: plugin_name = view_id.split('_')[0] view_meta_data = PluginRegistry.getInstance().getMetaData(plugin_name).get("view", {}) if isinstance(view_meta_data,list): continue #Skip unsupported case where View comes from a plugin with multiple views nallath, do you think I should report the issue on Github? Nvm, posted it. In the meantime, do you think there's any way to bypass this problem with code in the plugin, rather than modifying Uranium?
  3. Hello nallath. Thanks for answering. I've tried to do as you say, but I think my case is a little more complicated because I use 2 views in my plugin (as per your recommendation in another thread) or because of some previous undetected mistake I did. In your ModelCutter plugin, the only View (ChopperView) has no self.name assigned in its __init__(). Therefore, Cura automatically names the View as "ModelCutter" (the name of the plugin). In my plugin, I have 2 views with individual self.name values assigned (i.e. "SetupView" & "ResultsView"). Note that when I do this, they still get automatically appended the plugin's name (i.e. "FemPlugin_SetupView" & "FemPlugin_ResultsView"). The moment I open the Preview stage, I get a few errors stating that metadata (such as "view_panel" or "visible") could not be loaded: DEBUG - [MainThread] UM.Controller.setActiveStage [180]: Setting active stage to PreviewStage WARNING - [MainThread] UM.PluginRegistry._populateMetaData [778]: Could not find plugin FemPlugin_SetupView WARNING - [MainThread] UM.PluginRegistry._populateMetaData [778]: Could not find plugin FemPlugin_ResultsView DEBUG - [MainThread] UM.Controller.setActiveView [108]: Setting active view to SimulationView INFO - [MainThread] STLReader.STLReader.load_file [53]: Using NumPy-STL to load STL data. DEBUG - [MainThread] UM.Mesh.MeshData.calculateNormalsFromVertices [558]: Calculating normals took 0.00099945068359375 seconds DEBUG - [MainThread] STLReader.STLReader._read [105]: Loaded a mesh with 12612 vertices DEBUG - [MainThread] UM.View.GL.ShaderProgram.load [60]: Loading [C:\Program Files\Ultimaker Cura 4.11.0\plugins\SimulationView\simulationview_composite.shader]... WARNING - [MainThread] UM.PluginRegistry._populateMetaData [778]: Could not find plugin FemPlugin_SetupView WARNING - [MainThread] UM.PluginRegistry._populateMetaData [778]: Could not find plugin FemPlugin_ResultsView I've tried to pinpoint how is _populateMetaData() being called in Cura and Uranium's source code, with no success. I also do not understand why it says "Could not find plugin" yet uses the View's name rather than the plugin's name. Changing to Prepare or Monitor stages works fine and does not trigger these errors. Since it fails to load the metadata, it doesn't load the "visible" values you told me about in your post above and therefore the dropdown still shows the unwanted views. Many thanks for any help.
  4. Hello there. In default Cura, there are (at least) 3 Views: Solid, Simulation and X-Ray. In the Preview Stage, there is a View Selector (a dropdown menu) that lets you choose between Simulation (AKA Layer) and X-Ray views. The Solid View does not appear on the list. I would like to know how Cura selects which views appear/don't appear in this list. The only relevant difference I've found is that SolidView inherits from UM.View.View, while SimulationView and XRayView inherit from cura.CuraView. The reason I need this is that in the plugin I'm developing, I use 2 new views and I don't want them appearing here: If hiding my new Views is not possible, I'd like to at least make them appear last. When registering a View, there is a 'Weight' parameter which I guess dictates the load order, but I haven't managed to reorder them with it. Thanks.
  5. Hey, late reply but good news. What you want to do is exactly how Cura works behind the scenes. When adding a triangle (or quad, or line...), Cura uses setVertexColor() on each of its 3 vertices, but uses the same color so there's no gradient. What you can do is first create your mesh with your primitives, and afterwards go vertex by vertex changing the color. For example, I tested it on this cube I built for a project of mine. It's made up of 10x10x10 quads. Mind you, quads are actually just a pair of triangles: Then I used this code to randomize the color of every vertex: def PrepareMeshBuilder(self): ... [Here goes code to add primitives (tris, quads...), calculate normals, etc.] ... import random for vIndex,_ in enumerate(self.mb.getVertices()): r = random.randint(0, 255) g = random.randint(0, 255) b = random.randint(0, 255) self.mb.setVertexColor(vIndex, Color(r, g, b, 255)) And got this: Edit: If I were you, I would override or create a custom addFace() method that took 3 colors instead of 1 and applied them directly. This way you could create your triangles and paint them at the same time.
  6. In the FEM plugin I'm developing, I've got a disparity between color tones in the OpenGL-rendered object and in the color chart: For example, the max tension is represented as red (255, 0, 0, 1), both in rendering and inside QML. The 4 lower vertices of the cube have the max tension, so they should have the same red (but they're clearly pinkier). I'm rendering with the simplest shader, default.shader, so there's no special color or lightning effects (diffusion, specularity...) that I know of. I've just recently started learning about shaders. If we look at similar things that Cura does, there doesn't seem to be a great disparity between colors in rendering and colors in QML legends: Has the Cura team done something I'm missing?
  7. If you have access to Solidworks, the easiest way is to edit the original SLDPRT. You can create a revolved profile to fill the hole, for example. For editing the stl, you'd need a second stl with the shape of the conic hole you want to plug, and a program that can combine (boolean addition) both stls. MeshLab can combine stls, but can't create your 'plug'. Blender can do both, but is more complex. With Blender you can also manually edit the mesh, but I guess this is a bit advanced.
  8. [Hey ahoeben, I was just writing a solution I've found, which uses addLine(). Since I've got it almost written I'll just leave it here for anyone curious, but I'll try using a shader as you say] I've discovered that I can simply create a second mesh inside a single SceneNode, and then render each mesh separately. I discovered this by looking into Cura's BuildVolume class. More or less my code is this: 1) Create a _grid_mesh and build the wireframe with AddLine() 2) Override the SceneNode.render() method: def render(self, renderer): if (self.isVisible()): #To draw the colored faces -> The most simple rendering renderer.queueNode(self) #To draw the edges -> A Lines AKA wireframe rendering renderer.queueNode(self, mesh=self._grid_mesh, mode=RenderBatch.RenderMode.Lines) return True 3) Make sure the active view runs this render() I still can't control the lines' color though (always white).
  9. One additional related question if you don't mind: how would you approach drawing the edges (black lines delimiting each square) like in my first screenshot? 1) With addLine(): I've tried but for some reason the resulting mesh is not drawn correctly when combining addQuad & addLine. 2) Option 1 but putting the lines in a child sceneNode's mesh 3) Some shader or rendering option, if it exists 4) Implementing a custom shader, akin to how the Platform is a single quad but draws a 1x1cm mesh 5) Something else
  10. Thanks, ahoeben. It works now with this change: def buildMesh(self, geometryData): self.mb = MeshBuilder() self.resultsMeshBuilder(geometryData) self.mb.calculateNormals() #Added this line mesh = self.mb.build() self.setMeshData(mesh)
  11. Hello guys. Some time ago I made a little Python application to visualize the results of a FEM study, and now I'm integrating it into a Cura plugin. However, the resulting SceneNode's mesh looks completely gray/colorless: The steps followed to prepare the mesh are: 1) Calculate the coordinates and color of every square. The algorithm is pretty much the same as in the old application so I didn't change much. 2) Create a SceneNode object. Make it a child of the Root SceneNode. 3) Use addQuad() to actually build the mesh by drawing each little square. More or less like this: class ResultsNode(SceneNode): [...] def buildMesh(self, geometryData): self.mb = MeshBuilder() self.resultsMeshBuilder(geometryData) mesh = self.mb.build() self.setMeshData(mesh) def resultsMeshBuilder(self, geometryData): [...] #Code to find coordinates P1, P2, P3, P4 and color of each square color = Color(1.0, 0, 0, 1.0) #For now, just paint all squares RED for face in ListOfFaces: self.mb.addQuad(face.P1, face.P2, face.P3, face.P4, color) Geometrically, the mesh is built correctly (I've successfully tested other shapes). It's just the color that fails. If the code above is not the culprit, I suspect it might be the View. Is there somewhere I can learn about views, rendering and shaders (something more in depth than the Uranium docs)? Thanks.
  12. nallath's observation saved my skin: h5py's latest version requires Python 3.6, so it can't run on Cura (Python 3.5.x). However, a previous version (2.10.0) is still compatible. I've prepared a clean Windows 10 install (on a virtual machine to prevent any mix-up with different Python versions), There, I've installed the same Python version as Cura (3.5.4, 64 bit), pip-installed h5py 2.10.0, and copied the folder with the compiled files: C:/Users/xxxx/AppData/Local/Programs/Python/Python35/Lib/site-packages/h5py (might be Roaming instead of Local for some installs) This folder can now be used as a Python package. For some reason, a simple import fails so I have to do this: import os, sys dir = os.path.dirname(os.path.realpath(__file__)) #This script's path sys.path.append(dir) #Look for packages here import h5py f = h5py.File(testFile,"r") I still need to ensure an old h5py version suits my needs, and later repeat the process for Linux and macOS.
  13. I noticed that the compiled files were made for Python 3.8. Since Cura comes with Pyton 3.5.0, I repeated the process but this time using h5py compiled in a Windows system with Python 3.5.0 installed. This time, Cura crashes with this error: [...] h5py = cdll.LoadLibrary(path) #This replaces the usual "import h5py". h5py is now a usable module File "ctypes\__init__.py", line 429, in LoadLibrary File "ctypes\__init__.py", line 351, in __init__ OSError: [WinError 193] %1 is not a valid Win32 application
  14. Some time ago I made a python application which I am now integrating into a Cura plugin. It uses the h5py library, which is usually installed through pip. I assumed that copying the source code and using an 'import h5py' would be enough, but nope: the library is written in cpython, and when installed with pip it actually compiles into a bunch of dll and pyd files: I've unsuccessfully tried many ways to import it from this forum (1, 2), from StackOverflow (1), etc. Most methods involved copying the files compiled for my system, and loading them with ctypes or adding them to Path. The following method manages to import it without errors, but as soon as I use one of its classes it tells me it doesn't exist: import os from ctypes import * def LoadHDF5Data(filetoload): #We need to chdir because otherwise it will fail to find many dependencies os.chdir("C:\\Users\\myname\\AppData\\Roaming\\cura\\4.7\\plugins\\FemPlugin\\ResultsNode\\h5py") path = "C:\\Users\\myname\\AppData\\Roaming\\cura\\4.7\\plugins\\FemPlugin\\ResultsNode\\h5py\\hdf5_hl.dll" h5py = cdll.LoadLibrary(path) #This replaces the usual "import h5py". h5py is now a usable module f = h5py.File(filetoload, 'r') #Crashes Cura: "AttributeError: function 'File' not found" Anyone knows what the correct approach is?
  15. For anyone interested, I've been using Cura remotely for some time with VNC. I use UltraVNC server on a laptop with Cura. It works correctly as long as I keep the lid open (if the screen is off Cura and other applications freeze over VNC). On the other PC I use VNCViewer by RealVNC but anything should work.
×
×
  • Create New...