CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 23, 2019, 14:19:06 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Shapes to Points List  (Read 4533 times)
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5514



View Profile WWW
« 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:
' 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 » Logged
Garyhlucas
CNC Jedi
*****
Offline Offline

Posts: 1247


View Profile
« Reply #1 on: November 06, 2014, 18:50:46 pm »

Nicely done David!
Logged

Gary H. Lucas

Have you read my blog?
 http://a-little-business.blogspot.com/
lloydsp
CNC Jedi
*****
Offline Offline

Posts: 7914



View Profile
« Reply #2 on: November 06, 2014, 22:15:47 pm »

Ah, an "object snap-to-point" function!  Nice!
Lloyd
Logged

"Pyro for Fun and Profit for More Than Fifty Years"
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5514



View Profile WWW
« 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 !! Roll Eyes

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

++
David
Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1113


View Profile
« 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
Logged
Bubba
CNC Jedi
*****
Offline Offline

Posts: 2628



View Profile
« Reply #5 on: November 07, 2014, 00:51:34 am »

A great addition to CB.
As always.
 Thank you David. Wink Grin
Logged

My 2ยข
dsnellen
Storm Trooper
***
Offline Offline

Posts: 108


View Profile
« Reply #6 on: November 08, 2014, 17:42:26 pm »

Pretty cool. Thanks.

Dave
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5514



View Profile WWW
« 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

* Copy2PtList2.zip (1.66 KB - downloaded 59 times.)
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3965



View Profile
« Reply #8 on: December 09, 2018, 18:33:39 pm »

Merci ! excellent addition.
Logged

Made in England
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.16 seconds with 20 queries.

Copyright © 2018 HexRay Ltd. | Sitemap