Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of a cropmark editor to the extension #31

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

dodomarg
Copy link

In order to mitigate the difficulty of changing the default template I have created a cropmark editor the takes care of the needed changes to the document.
As TBH I did not fully understand the mechanism of the roland_cutsudio.py and was unable to edit the document to add the required data from the template to the current open document the addition is fully independent to the existing code and simply adds the ability for the user to edit the template once opened in any way they see fit.
The addition has been tested on a Roland GS2-24 with very good user feedback.
A behavior I was unable to understand caused the existing 3 cropmark template when sent to CutStudio to show as a four cropmark one, so for the lack of a better solution the editor offers the user 3 or 4 cropmark settings.
Test for the 3 cropmark performance were not carried out due to the issue mentioned above.

First version of a working editor with presets needs better comments
Changed id of the cropmark layer to be easily removable by the editor
A cheap workaround for inability to control the way cutstudio defines the number of cropmarks from Inkscape
Copy link
Owner

@mgmax mgmax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your great suggestion! I tested it and it looks like some bugs still need to be fixed: unit handling, cropmark position calculation and default margins. See the detailed review comments.

Comment on lines +37 to +39
# TODO add tool marks for manual alingment

# TODO impemnent a way to emmbedd the custom XML from template to any file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these comments still up to date?

Comment on lines +60 to +66
# Preset margins for machines
machine_margins = {
"gx_24_gs_24": {"top": 40.0, "bottom": 20.0, "left": 20.0, "right": 20.0},
"gr_g": {"top": 30.0, "bottom": 45.0, "left": 10.0, "right": 10.0},
"sv_series": {"top": 6.0, "bottom": 30.0, "left": 23.0, "right": 23.0},
"sv_8": {"top": 6.0, "bottom": 30.0, "left": 25.0, "right": 24.0},
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values do not match what I found in the Roland documentation. I successfully used the values from there with the GX24, which allows for a slightly larger cutting area:

https://files.rolanddga.com/Files/CutStudioManual/CutStudio/!SSL!/Responsive_HTML5/Hints_and_Tips/crop_position.html

H (float): Height in user units.
x (float): X-coordinate for the text.
y (float): Y-coordinate for the text.
font_size (str): Font size for the text. Default is "9pt".
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

font_size is no argument of the function.
Order of arguments is mixed up in the documentation ("parent" is at the end)

txt = parent.add(inkex.TextElement(**txt_attribs))


# Construct the cropmark settings string without the extra {{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean with "without the extra {{"?

"id": re.sub(r'\W+', '_', name), # Replace non-alphanumeric characters with underscores
"cx": str(x), # X position
"cy": str(y), # Y position
"r": "5" # Radius is half of the 10mm diameter
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in other places you assume that the document unit is millimeters. If I set the unit in the extension dialog e.g. to pt and choose page size A4 then the generated template is very wrong.

Comment on lines +250 to +256
# Convert numeric values to integers to remove decimal points
pageW = int(pageW)
pageH = int(pageH)
dx = int(dx)
dy = int(dy)
W = int(W)
H = int(H)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you convert to integer here? Custom pagesizes are not guaranteed to be in full millimeters.

Comment on lines +303 to +306
offset_left = bbox.left + margin_left + 10
offset_right = bbox.right - margin_right - 10
offset_top = bbox.top + margin_top + 10
offset_bottom = bbox.bottom - margin_bottom - 10
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is wrong with your cropmark computation.
In CutStudio 1.41 I see a difference of about 10 mm. With the old example template everything is correct.

screenshot

Comment on lines +35 to +36
3. ~~You now have an example file with DIN A4 pagesize and crop marks that should work on a Roland GX-24 (and hopefully many other plotters). Changing the page size and cropmark position is currently not possible.~~
You can edit the example file by Extensions -> Roland CutStudio -> Roland Cropmark Editor.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. ~~You now have an example file with DIN A4 pagesize and crop marks that should work on a Roland GX-24 (and hopefully many other plotters). Changing the page size and cropmark position is currently not possible.~~
You can edit the example file by Extensions -> Roland CutStudio -> Roland Cropmark Editor.
3. You now have an example file with DIN A4 pagesize and crop marks that should work on a Roland GX-24 (and hopefully many other plotters). You can change the page size and cropmark position with Extensions -> Roland CutStudio -> Roland Cropmark Editor.

# TODO impemnent a way to emmbedd the custom XML from template to any file

def add_arguments(self, pars):
pars.add_argument("--preset", help="Apply crop marks to...", default="gx_24_gs_24")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pars.add_argument("--preset", help="Apply crop marks to...", default="gx_24_gs_24")
pars.add_argument("--preset", help="Machine type (or 'custom' to use custom margins)", default="gx_24_gs_24")


def add_arguments(self, pars):
pars.add_argument("--preset", help="Apply crop marks to...", default="gx_24_gs_24")
pars.add_argument("--page_size", help="Apply crop marks to...", default="A1")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pars.add_argument("--page_size", help="Apply crop marks to...", default="A1")
pars.add_argument("--page_size", help="Page size (or 'custom' to use custom new_width and new_height, or 'keep' to keep old page size)", default="A1")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants