Author Topic: Shapes to Points List  (Read 13916 times)

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7400
    • View Profile
    • Cambam V1.0 French Doc
Shapes to Points List
« on: November 06, 2014, 16:52:55 pm »
Hello,

I just finish a little script that allow to copy one or more drawing object (of any type) to the matching position defined by the points of a point list.

Before running the script, select a point list then the other objects to distribute. The point list must be the first object in the selection.

The center of the drawing (teh cross) is used as center point for the objects to copy

a video here
http://www.screencast.com/t/47nvAjBGg42

The VB code

Code: [Select]
' shape to pointlist dh42 - 2014
' create a copy of the selected shape at each position of the point list

'select a point list and any drawing object - the point list must be the first selected object
'the center of the drawing is used as center for the objects to copy

sub main()

if view.SelectedEntities.Length > 1 then

dim first as boolean = true
dim pl as PointList

for each ent as Entity in view.SelectedEntities

'first entry must be a pointlist
if first = true then
if typeof ent is PointList then
pl = ent
first = false
else
msgbox("The first selected object must be a pointlist !")
exit sub
end if

else 'other entries after the point list

MoveShapeToPl(ent,pl)

end if

next ent

end if

end sub

Sub MoveShapeToPl(ent as entity, p as PointList)

'Copy and move a copy at each point in the point list

dim e as entity = New Entity()


'for each point in the pointlist

for each pt as Point3F in p.points

'copy the entity
e = ent.clone()
activelayer.Entities.Add(e)

'move the copy to the current point location
e.Transform.Translate(pt.x,pt.y,pt.z)

' apply transformation
if e.ApplyTransformation() then
   e.Transform = Matrix4x4F.Identity
end if

view.RefreshView()

next pt

End sub



++
David

Edit see here for last version
http://www.cambam.co.uk/forum/index.php?topic=4449.msg62026#msg62026
« Last Edit: December 09, 2018, 07:14:42 am by dh42 »

Offline Garyhlucas

  • CNC Jedi
  • *****
  • Posts: 1461
    • View Profile
Re: Shapes to Point List
« Reply #1 on: November 06, 2014, 18:50:46 pm »
Nicely done David!
Gary H. Lucas

Have you read my blog?
 http://a-little-business.blogspot.com/

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8964
    • View Profile
Re: Shapes to Point List
« Reply #2 on: November 06, 2014, 22:15:47 pm »
Ah, an "object snap-to-point" function!  Nice!
Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7400
    • View Profile
    • Cambam V1.0 French Doc
Re: Shapes to Point List
« Reply #3 on: November 06, 2014, 22:26:19 pm »
hello,

Yes, I need this function today ; I assume that I can use engraving + nesting to point list, then Toolpath to geometries,... but no luck Toolpath to geometries only convert the source toolpath, not the nested toolpath.

When I get time, I'll transform it in plugin and maybe I'll add some options like rotation, scale or autonumber for text ...

I can't retrieve the link to the API webpage in the cambam website ; it has disappeared ?? ... until I remember that I've the same link in the French doc !! ::)

http://www.cambam.info/doc/api/

++
David

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1820
    • View Profile
Re: Shapes to Point List
« Reply #4 on: November 06, 2014, 23:31:35 pm »
Yes this was a good idea, I can think of at least one instance lately where this script would have
saved quite a bit of time.
Thanks David

Offline Bubba

  • CNC Jedi
  • *****
  • Posts: 3355
    • View Profile
Re: Shapes to Points List
« Reply #5 on: November 07, 2014, 00:51:34 am »
A great addition to CB.
As always.
 Thank you David. ;) ;D
My 2ยข

Win11, CB(1.0)rc 1(64 bit) Mach3, ESS, G540, 4th Axis, Endurance Laser.

Offline dsnellen

  • Storm Trooper
  • ***
  • Posts: 108
    • View Profile
Re: Shapes to Points List
« Reply #6 on: November 08, 2014, 17:42:26 pm »
Pretty cool. Thanks.

Dave

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7400
    • View Profile
    • Cambam V1.0 French Doc
Re: Shapes to Points List
« Reply #7 on: December 09, 2018, 07:08:02 am »
Hello

A small addition to this script.

Now, it allow to define a rotation and/or scaling value to each copy (except the first one)



for scaling : a scale of 1.1 means 110% scaling ; the first copy is not scaled, the second is scaled 10% wider, the third 20% (of the initial size)

for rotation, negative values = rotate CW, positive = rotate CCW ; the first copy is not rotated

For using with a pointlist generated on a circle ( Divide Geometry &  Step Around Geometry) the first point is always at the right hand side, aligned on the X axis and the path turn CCW when used on a circle or a circle converted to a polyline. If you revert the polyline before the points creation, the start point is at the same place, but the path turn CW



++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5259
  • Made in England
    • View Profile
Re: Shapes to Points List
« Reply #8 on: December 09, 2018, 18:33:39 pm »
Merci ! excellent addition.
Filmed in Supermarionation

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7400
    • View Profile
    • Cambam V1.0 French Doc
Re: Shapes to Points List
« Reply #9 on: April 09, 2020, 00:02:38 am »
Hello

I just turn this script to a plugin for CB V1.0 (only) 32 & 64 bits

Not tested on Linux at this time ... (if someone test it on linux, a feedback would be appreciated ;))

http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/Copy2pointlist.html

++
David

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7400
    • View Profile
    • Cambam V1.0 French Doc
Re: Shapes to Points List
« Reply #10 on: April 10, 2020, 03:06:36 am »

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5259
  • Made in England
    • View Profile
Re: Shapes to Points List
« Reply #11 on: April 10, 2020, 07:48:32 am »
David,

It's a good plugin.
Filmed in Supermarionation