[BlenderBIM] - Storing reference drawing with the Ifc?

AceAce
edited March 2023 in General

Hi All,
Does anyone know in BlenderBim how to link an image to the Ifc so that when opening the Ifc it loads the image aswell?
Either in a way that directly stores the image in Ifc or that references it like an xref or link

«1

Comments

  • Either in a way that directly stores the image in Ifc or that references it like an xref or link

    Is using a custom IfcPropertySet with a single IfcProperty no option?

    Ace
  • Hey @Coen thanks for answering, I'm not sure exactly how using a property set? Are you saying to classify the image and use a property set to store it, or create an empty and link that to the image stored elsewhere?

  • If you mean a raster image, I think the safest way would be to create a material and map it on a plane geometry. I don't know of any viewers that support referenced images.

    Ace
  • edited March 2023

    @Ace

    Hey @Coen thanks for answering, I'm not sure exactly how using a property set? Are you saying to classify the image and use a property set to store it, or create an empty and link that to the image stored elsewhere?

    Almost, if I understand you correctly you want to automatically load an image in Blender which is attached to the IFC?

    If so, what about assigning a custom property to an IfcBuildingStorey? IfcBuildingStorey seems to me intuively the most logical places to store an image reference.

    Then save the IFC.
    Then you could use this code snippet to add the image planar to the IfcBuildingStorey

    import ifcopenshell
    import ifcopenshell.api
    from blenderbim.bim.ifc import IfcStore
    
    ifc_file = ifcopenshell.open(IfcStore.path)
    ifc_element = ifc_file.by_type("IfcBuildingStorey")[0]
    image = ifcopenshell.util.element.get_pset(ifc_element, "My Images","StringProperty")
    bpy.ops.object.empty_add(type='IMAGE',
                            radius=1,
                            align='VIEW',
                            location=(0, 0, 0),
                            rotation=(0, -0, 0),
                            scale=(1, 1, 1))
    bpy.ops.object.load_reference_image(filepath=image)
    


    I think you could also store different images for each IfcBuildingStorey and set the height of the image in BlenderBIM if you would like.

    theoryshawAceNaxela
  • edited March 2023

    No expert, but it seems like the following could be a way to tie an external image to geometry, in IFC.

    IfcImageTexture: https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/concepts/Partial_Templates/Texture/Image_Texture/content.html

    Unfortunately only a few examples out there.

    #50= IFCSTYLEDITEM(#48,(#52),$);
      /*#48= IFCTRIANGULATEDFACESET(#49...
        /*#49= IFCCARTESIANPOINTLIST3D...
      /*#52= IFCSURFACESTYLE($,.POSITIVE.,(#54,#55));*/
        /*#54= IFCSURFACESTYLERENDERING(#56,$,$,$,$,$,$,$,.NOTDEFINED.);*/
          /*#56= IFCCOLOURRGB($,1.,1.,1.);*/
        /*#55= IFCSURFACESTYLEWITHTEXTURES((#57));*/
          /*#57= IFCIMAGETEXTURE(.T.,.T.,'TEXTURE',#58,$,'C:\\dev\\Constructivity\\Constructivity.Renderer.Mono\\Textures\\diagnostic.png');*/
            /*#58= IFCCARTESIANTRANSFORMATIONOPERATOR2D(#59,$,#60,48.);*/
              /*#59= IFCDIRECTION((1.,0.));*/
              /*#60= IFCCARTESIANPOINT((0.,0.));*/
    
    CoenAcecarlopav
  • Would love to see this implemented.

  • Related clip

  • @Coen said:

    Related clip

    Would be cool if you could store reference images in IFC and would import it in BlenderBIM with this functionality added.

    theoryshaw
  • Don't know if it's any use, but I made a very rudimentary two buttons add-on which stores a reference image path to an IfcProperty of an IfcBuilding.
    When you click the Load Reference Image button, it will look into the IFC and set it back to Blender with the very basic settings. A next step would to preserve the settings of the image you've added as a property. This way you could store all these settings in IFC without having to save the blend file to keep the image transformations. Would also be nice if I could try to implement the functionality from the youtube clip I posted here above.

    I think the goal of this add-on would to preserve the transformations of the reference images in IFC you're modeling from in Blender.

    theoryshawAcecarlopavNaxela
  • Also, I have a hard time finding 2D architectural drawings in .pdf/.jpg/.png/.svg format in the public domain. The Schependomlaan has no PDFs. I remember someone made a thread here once where they listed some 2D plans. but I can't find it anymore.

  • edited April 2023

    With stored transformation of the image in IFC :-D

    I think this way it could save the underlay images with transformations applied in IFC and show them in Blender/BlenderBIM.
    This will prevent you from saving a seperate blend file if you are modelling with imported images.

    https://github.com/C-Claus/BlenderScripts/tree/master/BlenderBIM_add_reference_images

    I think it could be practica, what it does, it saves the file location of the image and transformation in a propertyset.

    So, next time you open your Blender session, you only have to click Load Reference Image
    And the image you wanted will appear exactly where you kept it the last time:

    theoryshawbrunopostleJanFBedsonbruno_perdigaoAceMassimocvillagrasabasweinengfernando
  • You are a legend @Coen !

    Coen
  • edited April 2023

    This is so awesome!
    Wasn't able to get it to work, as you GIF showed.
    https://www.dropbox.com/s/0qu3bwn2h3ngyl3/2023-04-23_20-11-25_Blender_blender.mp4?dl=0
    Curious, why associate it with IfcBuildingStorey? What if you have multiple images?
    Would think it would be a good to better codify this texture with a more appropriate IFC schema somehow, whatever that is.
    Perhaps IfcImageTexture.
    Here's some examples of IfcImageTexture being used in the wild.
    Also not sure the best class to associate it with, perhaps IfcVirtualElement.
    Not sure.

    Coen
  • @theoryshaw said:
    This is so awesome!
    Wasn't able to get it to work, as you GIF showed.
    https://www.dropbox.com/s/0qu3bwn2h3ngyl3/2023-04-23_20-11-25_Blender_blender.mp4?dl=0
    Curious, why associate it with IfcBuildingStorey? What if you have multiple images?
    Would think it would be a good to better codify this texture with a more appropriate IFC schema somehow, whatever that is.
    Perhaps IfcImageTexture.
    Here's some examples of IfcImageTexture being used in the wild.
    Also not sure the best class to associate it with, perhaps IfcVirtualElement.
    Not sure.

    You're absolutely right aboout everything you said in this post, I was just too excited and wanted to make it work as fast as possible. Also multiple images should be supported in the future, now it's just one image which overwrites the image A property. This whole add-on could be waaaaay better. It's just a fast 'sketch' to show if it could be possible.

    From your dropbox recording, I don't understand why it does not save the scaling, will take a good look. Won't have much time this week to be hobbying though :/

    You are a legend @Coen !

    Thanks, but please not too many compliments, they will inflate my ego too much ?

  • Just thinking out loud, would it be practical to reference the .png/.svg image outputted by BlenderBIM drawings in the 3D View so you would have a preview which could be toggled on and off?

    brunopostletlangbruno_perdigaoAce
  • @Coen said:
    Just thinking out loud, would it be practical to reference the .png/.svg image outputted by BlenderBIM drawings in the 3D View so you would have a preview which could be toggled on and off?

    I don't know if it would be practical but it would be awesome

  • Made some small progress, you are now able to load multiple image references with transformations in IFC at once:

    Let's say you already saved the images with transformation settings:

    In the add-on, you can now click this button which will load all the images:

    It's not really intuivite yet, when you click the plus icon there is no feedback the properties have been stored in IFC under IfcBuilding
    Also be aware it does not work when you use the yellow squares to drag the image. I think that's when you actually resizing the image instead applying a transformation to it.

    bruno_perdigaotheoryshawAce
  • And a more general question. BIMVision always notifies you with a pop-up changes have been made to the IFC. With BlenderBIM is not always clear to me if my changes were succesful, when I click the Reload IFC File button under IFC Project it prompts for a file location, then it crashes. I think a bug? I would have think when you click the button it would already know where the IFC path is.

  • @Coen Hi, would it be possible to save relative links as well? With our repo workflows with collaborators, the absolute path is always different.

  • A little late to the party, but I reckon an IfcAnnotation might be more appropriate to store the image reference. I also believe we can support it using regular image textures (which we do support) rather than a custom property set.

    Reload IFC File doesn't actually do anything if I recall :) Reload functionality hasn't been implemented.

    Coen
  • Would It be possibile to also store a reference to a point cloud so we can avoid reloading It every time with Blender point cloud visualizer? Thanks!

  • edited May 2023

    @theoryshaw said:
    @Coen Hi, would it be possible to save relative links as well? With our repo workflows with collaborators, the absolute path is always different.

    Will take a look, I think some kind of toggle button between relative and absolute path could be possible

    @Moult said:
    A little late to the party, but I reckon an IfcAnnotation might be more appropriate to store the image reference. I also believe we can support it using regular image textures (which we do support) rather than a custom property set.

    Do you have any code examples to store an delete stuff from IfcAnnotation ? :-).

    @carlopav said:
    Would It be possibile to also store a reference to a point cloud so we can avoid reloading It every time with Blender point cloud visualizer? Thanks!

    I'm not too experienced with point clouds. But now I am thinking more high over: How to reference external project data in IFC?
    BlenderBIM is ofcourse perfect for this. But I'm wary of storing external project data everywhere just because we can. Maybe some kind of general UI in Blender for the purpose of storing external project data like drawings, point clouds, calculations, pdfs? Or does this already exist?

    carlopav
  • @theoryshaw said:
    @Coen Hi, would it be possible to save relative links as well? With our repo workflows with collaborators, the absolute path is always different.

    I just discovered you can just set any string you want in the folder menu of Blender, however when I write it as a property in IFC it just turns into a dumb string and I can't use it anymore as path. Any suggestions?

  • I just discovered you can just set any string you want in the folder menu of Blender, however when I write it as a property in IFC it just turns into a dumb string and I can't use it anymore as path. Any suggestions?

    Any answers here? https://github.com/IfcOpenShell/IfcOpenShell/search?q=relpath

    Coen
  • edited May 2023
    from pathlib import Path
    path = Path(your_path)
    

    ? pathlib is supposed to be the successor of os.path so I suggest you try to use it as much as you can.

    @carlopav I'm working on something thanks to @Coen 's script I took inspiration from. Here's a snippet.
    I just have to find a way to store the clip planes live object matrix and it should be all good

    carlopavtheoryshawCoenAce
  • The following snippet is supposed to delete a pset by name, but it doesn't work, I might be doing something wrong.

    ifc                 =   ifcopenshell.open(IfcStore.path)
     element             =   ifc.by_type("IfcBuilding")[0]
    products            =   ifc.by_type('IfcProduct')
    
    for ifcproduct in products:
        if ifcproduct.IsDefinedBy:        
            for ifcreldefinesbyproperties in ifcproduct.IsDefinedBy:
                if (ifcreldefinesbyproperties.is_a()) == 'IfcRelDefinesByProperties':
                    if ifcreldefinesbyproperties.RelatingPropertyDefinition.is_a() == 'IfcPropertySet':
                        if (ifcreldefinesbyproperties.RelatingPropertyDefinition.Name):
                            if (ifcreldefinesbyproperties.RelatingPropertyDefinition.Name) == active_object_name:
                                ifcopenshell.api.run("pset.remove_pset", ifc, product=element, pset=ifcreldefinesbyproperties.RelatingPropertyDefinition)
                                bpy.data.objects.remove(bpy.data.objects[image_name], do_unlink=True)
    

    I want to delete a pset looping through all the psets names until there is a match, but it creates nested for loops and if statements. The code smell is horrendous. Is there a better way of doing this?

  • Yup these look really low-level accessors. You might be interested in how it's done inside the Blenderbim addon's tool module
    https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/blenderbim/blenderbim/tool/pset.py#L28-L31
    pset = ifcopenshell.util.element.get_pset(element, pset_name)
    and inside ifcopenshell-python
    https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcopenshell-python/ifcopenshell/util/element.py#L22-L89

    Coen
Sign In or Register to comment.