@Thom_Krejci (Thom Krejci) posted a new topic, subject "Match Paint Material for Paint Material Command". It read:

   Continuing the discussion from Extract face material information:
    
    Is there a way to match the material that was painted on a face and start the Paint tool with that material?
    
    With the post linked above, I was able to create the following flow where you can interactively select a face and have Dynamo report what material is on the face.
    
    Thanks again!
    
    Get the Material of a Selected Face.dyn (13.7 KB)

To which @Dimitar_Venkov (Dimitar Venkov) replied

    You can trigger the paint tool as a postable command but I'm not aware of any way that can set the material used with it. The document class has methods for setting a default family and element type but nothing on materials.
    
    Alternatively, if you know the faces that need to be painted, you can directly use the Document.Paint method.

To which @Thom_Krejci (Thom Krejci) replied

    Thank you very much for that insight!
    
    -Thom K.

So @Steven (Steven) replied

    You can have dynamo copy the material name to the clipboard and start the command as @Dimitar_Venkov has said. You can then just past the name into the material and Revit will search for it. Not a 100% solution but would help out a lot.

Then @Steven (Steven) said

    Here is my interpretation of what you have done. Thanks for starting the post. They python code at the end was borrowed from @john_pierson Rhythm Package ( _PostableCommand.Default3DView_ ). I only changed “Default3DView” to “Paint” API found here Thanks John and @Dimitar_Venkov
    
    image.png1570×410 39.8 KB
    
    Material on Face and Start Paint.dyn (7.9 KB)

Then @Thom_Krejci (Thom Krejci) said

    Greetings Steven,
    
    That works quite well, thank you very much for putting that together.
    
    There seems to be some issue with it remembering what it last did and not truly running it tabula rasa. I've seen this on other scripts too where I'd have to either close the DYN or relaunch Dynamo for it to ‘forget'.
    
    If there's some insight or maneuvering, I'd certainly appreciate it.
    
    Thank you very much for connecting those dots!
    
    -Thom K.

Then @Steven (Steven) said

    I am not quite sure. Is the Python producing and error?
    
    You can try this maybe:  
    Select a new face and set the Boolean to False. Hit Run  
    Set the Boolean to True. Hit Run  
    Select a new face and set the Boolean to False. Hit Run  
    Set the Boolean to True. Hit Run  
    .  
    .  
    .  
    Have you tried it with the Player? I am sorry I have not used it that much to find an error with it.

So @Thom_Krejci (Thom Krejci) replied

    Sorry for the delayed response:
    
    I haven't received any errors with anything in Dynamo: It's just that if I paint with material A, then paint with material B, and then run the tool to match material A, it just selects/sets the last material I painted with.
    
    I haven't had a chance, but I will try out your proposed process and see what happens.
    
    Thank you again!!  
    Thom K.

So @Steven (Steven) replied

    The Revit tool will always default to the last material you painted with. My script, (sorry if I did it backwards from what you want) you select the face and it will copy the material name to your clip board. If the Boolean is set to true it will activate the paint command (by default it has the last material you painted with) you can hit ctrl+v on your keyboard to past the name of the material into the search box. Revit will then filter to the material. Select the material and then you can paint with it.

Then @Thom_Krejci (Thom Krejci) said

    Oh, I would never look a gift-script in the mouth!
    
    Your description is the workflow that I was hoping for. For whatever reason, Dynamo/Revit don't like running the script multiple times without closing Dynamo and selecting the face didn't always push the material into the clipboard.
    
    It works as intended, I think there is just some internal things with Dynamo/Revit that cause some inconsistent results.
    
    Thank you again for your perseverance.  
    Thom K.

After which, @Steven (Steven) added

    Oh ok I under stand what you are saying. If you have access to Revit 18.2 with the Dynamo player it should work each time as this is running a fresh copy each time you press play.
    
    If you could please marked solved (if you think this has been solved) so others can find the answer as well.

So @Thom_Krejci (Thom Krejci) replied

    Excellent!
    
    Thank you again for your responses and work.  
    Thom K.


{'source': 'discourse', 'url': 'https://forum.dynamobim.com/t/match-paint-material-for-paint-material-command/20564', 'title': 'Match Paint Material for Paint Material Command', 'views': 1395, 'has_accepted_answer': True, 'word_count': 757, 'like_count': 4, 'reply_count': 10, 'participant_count': 3, 'posts': 12, 'tags': '', 'author': '@Thom_Krejci (Thom Krejci)', 'participants': '@Thom_Krejci (Thom Krejci), @Dimitar_Venkov (Dimitar Venkov), @Steven (Steven)', 'image_url': ['https://global.discourse-cdn.com/business6/uploads/dynamobim/optimized/3X/e/8/e81b5e9aacdd449e58cb364f4b1e7c26dbc4c518_2_1024x221.png'], 'created_at': '2018-03-29T13:55:29.624Z', 'last_posted_at': '2018-04-06T12:29:55.231Z'}