My main goal is to save all vector data and import it in another software (something like SVG). But, I'm little confused about the shape data. Please download following file: https://drive.google.com/file/d/1oBj75F ... drive_link
You can see there is one shape, but 3 sub shape. how I can split points on those 3 shapes?
https://drive.google.com/file/d/1Snuco_ ... drive_link
The thing that I need is 3 table of points based on what you can see in the image.
Get Shape Points
Moderators: Víctor Paredes, Belgarath, slowtiger
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
- synthsin75
- Posts: 10264
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Get Shape Points
You'll probably need to check which curves are in the shape. If that fails, you may need to check end points and adjacent points on the curve to build your tables.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Get Shape Points
Thanks, I used adjacent method and it works:synthsin75 wrote: ↑Sat Aug 10, 2024 9:14 pm You'll probably need to check which curves are in the shape. If that fails, you may need to check end points and adjacent points on the curve to build your tables.
Code: Select all
-- **************************************************
-- General information about this script
-- **************************************************
ScriptName = "MZ_Test_Script"
MZ_Test_Script = {}
function MZ_Test_Script:OnMouseDown(moho, mouseEvent)
end
function MZ_Test_Script:DoLayout(moho, layout)
layout:AddChild(LM.GUI.Button('Get Points Table', MOHO.MSG_BASE))
end
function MZ_Test_Script:HandleMessage(moho, view, msg)
MZ_Test_Script:GetPointsTable(moho)
end
-- **************************************************
-- Functions
-- **************************************************
function MZ_Test_Script:GetPointsTable(moho)
local doc = moho.document
local frame = moho.frame
local layer = moho:LayerAsVector(doc:LayerByName('Foot'))
local mesh = layer:Mesh()
local shape = mesh:Shape(0)
local points_table = {}
local points_sub_table = {}
table.insert(points_table,points_sub_table)
for i = 0, shape:CountPoints() - 1 do
if (i > 0) then
if mesh:ArePointsAdjacent(shape:GetPoint(i),shape:GetPoint(i-1)) == false then
points_sub_table = {}
table.insert(points_table,points_sub_table)
end
end
table.insert(points_sub_table,mesh:Point(shape:GetPoint(i)))
end
return points_table
end
- synthsin75
- Posts: 10264
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Get Shape Points
That's why I mentioned endpoints. You're tables don't seem to be getting the points in the correct table.
If you add this code, you can see how the endpoints are being put in the tables.
The first curve is correct, 24 points with no endpoints. But your second curve only shows 3 points with one endpoint, and it's other endpoint is ending up in the errant 4th table.
Code: Select all
for i,v in ipairs(points_table) do
for d,k in ipairs(v) do
print(i, " ", d, " ", tostring(k:IsEndpoint()))
k.fSelected = k:IsEndpoint()
end
end
The first curve is correct, 24 points with no endpoints. But your second curve only shows 3 points with one endpoint, and it's other endpoint is ending up in the errant 4th table.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Get Shape Points
So, what the final code should be?synthsin75 wrote: ↑Sun Aug 11, 2024 2:55 pm That's why I mentioned endpoints. You're tables don't seem to be getting the points in the correct table.
If you add this code, you can see how the endpoints are being put in the tables.Code: Select all
for i,v in ipairs(points_table) do for d,k in ipairs(v) do print(i, " ", d, " ", tostring(k:IsEndpoint())) k.fSelected = k:IsEndpoint() end end
The first curve is correct, 24 points with no endpoints. But your second curve only shows 3 points with one endpoint, and it's other endpoint is ending up in the errant 4th table.
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Get Shape Points
This file is imported from old Moho version 9.5 to 14, it seems it has so many internal problem, please someone approve this:
two points are in the same curve, but point:Curve(0) return different curve:
https://drive.google.com/file/d/17490I3 ... drive_link
two points are in the same curve, but point:Curve(0) return different curve:
https://drive.google.com/file/d/17490I3 ... drive_link