Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

After cut and paste the object can not be removed

Engaged ,
Oct 27, 2024 Oct 27, 2024
The following scenario gave me an error. What is wrong?
 
1. create new layer // it becames a current layer
2. draw point (ellipse). // obj ref is `point`
3. cut & paste
4. deselect all
and 
point.selected = true;
point.remove();
 
sdf.png
TOPICS
Scripting
302
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Oct 28, 2024 Oct 28, 2024

In this scenario, I managed to delete this point by setting a note for it and then finding it by searching among pageItems. 

Nevertheless, it is also interesting to know other solutions.

Translate
Adobe
Community Expert ,
Oct 27, 2024 Oct 27, 2024

@andyf65867865 - Could you please share code what exactly you are processing. Tried the following snippet based on your steps and it works well

 

var _doc = app.activeDocument;
var _layer = _doc.layers.add();
var _point = _doc.pathItems.ellipse(0, 0, 30, 30);
app.executeMenuCommand('cut');
app.executeMenuCommand('paste');
app.executeMenuCommand('deselectall');
_point.selected = true;
_point.remove();

 

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 27, 2024 Oct 27, 2024

Hi @Charu Rajput, please try this. 

 

(function() {
    var doc = app.activeDocument;
    var newLayer = doc.layers.add();

    var point = doc.pathItems.ellipse(0, 0, 1, 1);
    point.filled = true;
    var whiteColor = new CMYKColor();
    whiteColor.cyan = 0;
    whiteColor.magenta = 0;
    whiteColor.yellow = 0;
    whiteColor.black = 0;
    point.fillColor = whiteColor;
    point.stroked = false;

    app.executeMenuCommand('Find Fill Color menu item');
    app.executeMenuCommand('cut');
    app.executeMenuCommand('pasteFront');
    app.executeMenuCommand('deselectall');

    point.selected = true;
    point.remove();
})();

 

It seems that it is the 'Find Fill Color menu item' followed by cut & paste that is causing this error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2024 Oct 28, 2024
LATEST

In this scenario, I managed to delete this point by setting a note for it and then finding it by searching among pageItems. 

Nevertheless, it is also interesting to know other solutions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines