Comments (5)
Hi @brightendavid Get the currently active document and layer activity to set a new name.
Below is a real code
from photoshop import Session
with Session() as ps:
layer = ps.active_document.activeLayer
print(f"old name: {layer.name}")
layer.name = "new name"
print(f"new name: {layer.name}")
Let me know if this works for you
Cheers,
Hal
from photoshop-python-api.
`from photoshop import Session
"""Import a image as a artLayer."""
Import local modules
with Session(action="new_document") as ps:
desc = ps.ActionDescriptor
desc.putPath(ps.app.charIDToTypeID("null"), r"C:\Users\new_data\plan2\pic_test_file\src.png")
event_id = ps.app.charIDToTypeID("Plc ") # Plc
need one space in here.
ps.app.executeAction(ps.app.charIDToTypeID("Plc "), desc)`
I am sorry not express well . look at the example,this is the example file you applyed.the added layer may always have the name src.and I just can't rename the layer .The added layer may not have the attribute "Name".
from photoshop-python-api.
@brightendavid
I have quickly tested its works, could you please give more context information(python version, photoshop version, and error screenshot)?
from photoshop import Session
with Session(action="new_document") as ps:
desc = ps.ActionDescriptor
desc.putPath(ps.app.charIDToTypeID("null"),
r"C:\Users\hallong\Pictures\332-3328628_refresh-icon-vector-clipart.png")
event_id = ps.app.charIDToTypeID("Plc ") # `Plc` need one space in here.
ps.app.executeAction(ps.app.charIDToTypeID("Plc "), desc)
layer = ps.active_document.activeLayer
layer.name = "new_name"
from photoshop-python-api.
thank you very much ,it is all right now. I may make a mistake.
from photoshop-python-api.
You're welcome!
Closing the issue.
from photoshop-python-api.
Related Issues (20)
- how I close the ps.exe safely, ps.Application() seems no such function like "close() / quit()" HOT 2
- 多次替换psd中同一个图片,并在每次替换后将替换后的psd保存为png。在这个过程的第二次开始,它会将上一次保存的png替换到想要替换的图层上,描述可能有点不清晰,代码如下 HOT 1
- selection.select()如何设置只选中文字 HOT 1
- How to rollback operations? HOT 1
- How to revert changes? HOT 1
- Change the ps version
- Any example for read TIF file
- 如何使用这个api调整笔刷旋转角度 HOT 1
- How to Replace Smart Layer Text with a Script
- How to hide the Photoshop window
- How to adjust HDR Toning
- Photoshop API with python multithreading HOT 2
- How to import data group txt file and export data group as file
- 无法在mac 电脑上使用 建议兼容一下 HOT 2
- `slelect` method is missing in Code Reference HOT 1
- About the bottomed API reference HOT 1
- Replacing multiple layers with images does not work; it only replaces the same layer multiple times
- PSB Save options available?
- How to get the rotation angle of a layer
- Can I give an example of applying gradients to a text layer style HOT 3
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 photoshop-python-api.