Development version shape library

Having problems with or questions about SheetCam? Post them here.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

What's your timeline looking like for the next stable release? With the flood of projects around the holidays, I haven't had much time to work on the new shapes I mentioned.
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Development version shape library

Post by Les Newell »

At the rate things are going I'd say around the end of January. I had hoped to have things a bit more settled by now.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

Hey Les, working on a few more shapes here and i think i am running into some issues with your location code for the shapes. This isn't behaving anything like I expected. I expected to set the X,Y location to 0,0 and The coordinates would be whatever i type in X1, Y1, X2, Y2, but the line is totally dependent on the X,Y location input somehow. Can you see what is going on here?
SheetCam-TNG-Development-CoryMil.zip
(1.21 MiB) Downloaded 80 times

Code: Select all

function shape.Calculate()
	MoveTo(shape.X1, shape.Y1)
	Line(shape.X1, shape.Y1, shape.X2, shape.Y2)
 end
Also, i dont remember if the update has been released yet or not, i dont think it has, but the X position on the text plugin is still doing something wonky and the shape plugin X,Y are not auto-updating.
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Development version shape library

Post by Les Newell »

David_Lelen01 wrote: Fri Apr 30, 2021 12:44 pm Hey Les, working on a few more shapes here and i think i am running into some issues with your location code for the shapes. This isn't behaving anything like I expected.
The datum for the X,Y coordinates is always the centre of the outline of your shape. In your example the datum point would be half way between X1,Y1 and X2,Y2.
Also, i dont remember if the update has been released yet or not, i dont think it has, but the X position on the text plugin is still doing something wonky and the shape plugin X,Y are not auto-updating.
These are fixed for the next release. Stable should be out today. Dev will probably be out sometime next week.
In shape, entering values in X and Y does work, it just doesn't update the display. If you force a redraw, for example by zooming in or out you it will be shown in the correct place.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

The datum for the X,Y coordinates is always the centre of the outline of your shape. In your example the datum point would be half way between X1,Y1 and X2,Y2.
That still does not explain the behavior i am seeing, unless i just totally dont understand something here. It seems to me it is completely ignoring my X1, Y1 Point and trying to generate the line off of the center point. And not all of the shape main.lua codes use the centroid as the origin of the shape, so how does that work? I think i need to know more about how your datum point works to make this shape work correctly.
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Development version shape library

Post by Les Newell »

When you create a shape it is normalised so that X0Y0 is the centroid. The part coordinates are then added to set the final position.
Are you trying to position your shape at an absolute position on the sheet?
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

Are you trying to position your shape at an absolute position on the sheet?
Yeah, thats exactly my intent. I was trying to make a line that i could place at an exact location. Not sure how i could do that if every shape is normalized. It would work, you would just have to calculate the centroid when placing the shape instead of starting a line on a known point and going from there like i intended.
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Development version shape library

Post by Les Newell »

It wasn't really designed to work in absolute positioning. How come it doesn't surprise me you're trying to get it to do something it wasn't designed to do? :lol:
User avatar
djreiswig
Posts: 471
Joined: Sat Feb 20, 2016 4:47 am
Location: SE Nebraska

Re: Development version shape library

Post by djreiswig »

I don't use shapes, but can't you just put a formula in the post to calculate the center of the shape and offset the alignment?
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

It wasn't really designed to work in absolute positioning. How come it doesn't surprise me you're trying to get it to do something it wasn't designed to do? :lol:
Me?? Try to make something do something it was never intended to do? I wouldn't dare! lol :lol: Idk, that's kinda my job, Les lol.

Maybe its worth considering redesigning for absolute positioning. Every single time i have used the shape library i always have a specific position and rotation i want it on the sheet. Hopefully some others will chime in with their opinions.
I don't use shapes, but can't you just put a formula in the post to calculate the center of the shape and offset the alignment?
That is possibly an option, but i am not sure if it would simplify what i am trying to do any. I am trying to place a shape in a specific position relative to other geometry already on the sheet layout. yes, im sure it could be done in the post, but it would be far easier to just use the nesting and alignment functions already in sheetcam. I am just hoping to simplify the process of doing it in sheetcam to one step.
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Development version shape library

Post by Les Newell »

The shape will always be normalised so the centroid is at 0,0. That is a part of the way SheetCam's internals work and it's not practical to change this.
However you should be able to force the shape position. At the end of shape.Calculate() add this:
tempObj:SetPosition2D(sc.Coord2D(x,y))

x and y are the absolute coordinates of the centroid of the shape.
Note this is untested so it may have unexpected side effects.
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

Note this is untested so it may have unexpected side effects.
I'll be glad to test it out for you :lol: Thanks Les!
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

Hey Les, So far, I have not been able to make that line of code do anything. the shape normalizing code must be overriding it or something.
User avatar
Les Newell
Site Admin
Posts: 3661
Joined: Thu May 11, 2006 8:12 pm

Re: Development version shape library

Post by Les Newell »

It is moving the shape but it doesn't update the displayed coordinates. Try this instead:

Code: Select all

   tempObj:SetPosition2D(sc.Coord2D(x,y))
   posX.value:op_set(x)
   posY.value:op_set(y)
   posX.editor:GetValidator():TransferToWindow()
   posY.editor:GetValidator():TransferToWindow()
David_Lelen01
Posts: 452
Joined: Wed Sep 12, 2018 8:18 pm
Location: South Carolina, USA
Contact:

Re: Development version shape library

Post by David_Lelen01 »

That didn't exactly work either Les... Here's the error if it is inside the function block, which i think is wrong placement:
inside.PNG
inside.PNG (108.17 KiB) Viewed 2987 times
And here's if its placed after the function end:
outside.PNG
outside.PNG (58.3 KiB) Viewed 2987 times
and heres the code:
code.PNG
code.PNG (42.19 KiB) Viewed 2987 times
Post Reply