Macro for Toggling Transparency of Components

Hello forum,

My 1st post here! looking for a macro which I think might be helpful for all actually.

So you know how you can use tab and shift-tab to hide & unhide hovered components; love that feature, super convenient, right?

Can something like that be done but for transparency (basically a toggle)? Hover would be best, but I assume it won’t be as easy? How about pre-selecting the component, press a key (assigned to the said macro), make the part transparent, click again and make it opaque? I searched for such a macro a bit, no luck.


Thanks in advance!
Vahid

There’s no need for a macro. Toggle transparency is already a button in the UI. You can map the command to a shortcut key.

Hi Josh,

I’m using 2020 and transparency toggle or anything like that won’t shop up in the commands (under keyboard tab in customize menu) when you search for it.

I think this shows up by default when you click on a part
image.png

According to the swamp the answer is no. It is an old thread, but has replies from the last few months.

https://r1132100503382-eu1-3dswym.3dexperience.3ds.com/#community:yUw32GbYTEqKdgY7-jbZPg/iquestion:NX3vPl18Rma-9ijKAr-pKg

If you are trying to write a macro, I think this is the call you are looking for.

https://help.solidworks.com/2020/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.imodeldocextension~transparency.html?verRedirect=1

Yeah I am aware of that, but I’m trying to avoid the extra clicks. I like to be able to assign a key to it and toggle quickly between opaque and transparent, solidworks currently doesn’t allow that, hence my inquiry about a macro that can do that.

Thanks for the link…for a second I thought I’m missing something after josh comment, but yeah definitely you can’t assign a hotkey to this command without a macro.

As for the api link, unfortunately I am not knowledgeable enough to write the macro :frowning:

I went through the settings in SW and couldn’t find it either.

SPR184416 – Unable to assign a hot key to “Change transparency” (short cut key quick )

Found this thread from eng-tips which is about same request; but the link referenced there to the macro is dead

https://www.eng-tips.com/viewthread.cfm?qid=140985

Hello JSculley, where can I see a list of these SPRs. Do you have a link?

This will take you to the knowledge base. From there you can search for that SPR.

https://support.3ds.com/knowledge-base/

Based on that link, it is possible the creator of these forums could be the author of that macro.

matt
image.png

This is a one-liner macro. You can easily assign it to a hot key. Pre-selection of one or more components is required.

Dim swApp As Object
Sub main()
    Set swApp = Application.SldWorks
    swApp.RunCommand swCommands_e.swCommands_ChangeTransparency, ""
End Sub

Nothing will show up when I look up this SPR:
image.png

Thanks! I will give it a try, hopefully SOLIDWORKS add it with the hover functionality!

That’s a really REALLY old link. 20 years old or more. I think that’s an address I had when I lived in Rochester. REALLY old. 20+ years.

Verizon.net as your first website host Matt… <()> :laughing:

Can you dig up that macro for me please? Just kidding.

At least it wasn’t a MySpace page. :slight_smile: