CamBam
Resources => Scripts and Plugins => Topic started by: dh42 on September 10, 2011, 16:10:40 pm
-
Hello,
I begin to play with script in VB, the thing I wish to do is a "select by object type".
the goal is to select all objects of a same kind (circles, points, polylines) on the visible layers
After exploration of the script in the CB folder, if found how to test the kind of an object in a selection list, how to unselect all, but not how to unselect the current object or, other way to do, to get a list of all objects on visible layers (even unselected objects) and select or unselect it.
I try to write this : test object by object in the selection and unselect the current object if not a circle ... but that don't works :'(
sub main
'unselect other than Circle object in current selection
if view.SelectedEntities.Length > 0 then
for each ent as Entity in view.SelectedEntities
if typeof ent is Circle
ent.Selected=true
else
ent.Selected=false
end if
next ent
end if
view.RefreshView()
end sub
Is there someone that can help my to write that ?
thanks
++
David
-
Sorry for overlooking this one David,
Here is a solution:
sub main
'unselect other than Circle object in current selection
dim newselection as ArrayList = new ArrayList()
for each ent as Entity in view.SelectedEntities
if typeof ent is Circle
newselection.Add(ent)
end if
next ent
view.Select(newselection.ToArray())
view.RefreshView()
end sub
I hope this helps!
-
Hello Andy,
Yes !! nice thats help me ;D
thanks
++
David
-
Hello,
I add a windows for selection of the kind of shape.
Why the shapes are not selected in the layer tree ? the tree must be refreshed too ?
++
David
-
Anywhere within your script, add this line...
CamBamConfig.Defaults.ReloadTreeAfterScript = false
Normally, after a script has finished executing some code is run to reload the drawing tree view (in case the script has changed anything within the drawing).
ReloadTreeAfterScript = false will prevent this happening, so your selections will stay in place.
I also notice the 'after script' code also does a view.RefreshView(), so you could also leave out that line in your script.
The ReloadTreeAfterScript property is not saved in the configuration file, so the next time CamBam is restarted it's value will revert back to 'True'.
-
Hello,
OK, thanks Andy ;)
++
David
-
Hello,
My script don't works on N, I get this message.
Une exception a été levée par la cible d'un appel.
Impossible d'effectuer un cast d'un objet de type 'System.Object[]' en type 'CamBam.CAD.Entity[]'. :o
Help !!! ;D
++ ;)
David
-
Sorry about that one! :-[
Change this line...
view.Select(newselection.ToArray())
to
view.Select(newselection.ToArray(GetType(Entity)))
OR,
you can change
dim newselection as ArrayList = new ArrayList()
to
dim newselection as Generic.List(of Entity) = new Generic.List(of Entity)()
but not both! ;)
-
Hello,
Thanks ;D
No chances that I found that myself :o
There is a change ; when I choose "polyline", the polyrectangles are selected too (but if I choses "polyrectangle" the polylines are not selected)
The polyrectangles are assimilated to polylines in rev N ?
Nice that ability to resize the rectangle by mouse ;D
It would be nice if we could draw and place the stock bloc in the same way ;)
++
David
-
Hello,
Here is the plugin version for this tool.
++
David
-
Thanks, David. I'll try it ASAP.
Lloyd
-
NICE, David! I'll be using that frequently.
Can you make the selection of type "clickable"?
That's neat. Is source coming?
Lloyd
-
Hello Lloyd,
Can you make the selection of type "clickable"?
Yes, it's planed for next release (and with multiple choice)
the sources is attached ;) see reply #18
++
David
-
Thank you sir! New tricks to learn!
Lloyd
-
Hello,
A little release that add buttons to select the shape type.
++
David
-
Hello,
A new release that add a filter for arcs and circle (min and max radius/diameter)
http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/select_by_objtype.html
++
David
-
Marvelous, David! (and fast!) Thank you for the work.
Lloyd
-
Marvelous, David! (and fast!) Thank you for the work.
Lloyd
+1
-
And the source ;)
++
David
-
A very minor problem, David.
You're rounding the range window entries to "thousandths", which might be OK for mm measures, but is too great a tolerance for inch measures. We need it to 'tenths' (of thousandths... 4 digits past the decimal).
Lloyd
-
A very minor problem, David.
repaired ;)
download version 1.101 on the web site
++
David
-
Thank you so much! I've already used this feature to benefit.
Lloyd
-
Hi David
Please add filter to lines length to your plugin. The Inkscape's DXF contains a lot of zero length lines. It could be great to have a tool which allows to select and remove all of them.
-
Hello
I think that maybe this other plugin can do the trick for this usage.
http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/FileCleaner.html
++
David
-
David,
any chance for a version for CB 1.0? It happened so that I needed selective selection - to remove surfaces from an imported .stp file and leave the 'skeleton' geometry.
Somewhere in this thread I found a script from your early work, downloaded it, modified it with what Andy wrote as advice and did the work anyway. :)
-
Hello
This plugin is also working on CB 1.0 (I use it regularly)
++
David
-
Forgot to say that I had CamBam for Linux in mind. Didn't work when I tried.
-
Were there any error messages indicating why it didn't work ?
-
No, the moment I click on 'select by object type' in the Edit menu CB simply terminates without any error message.
No complaining messages on starting CB.
Now it came to my mind - could it be because I am running 64 bit version?
-
Hello
Now it came to my mind - could it be because I am running 64 bit version?
No, this plugin is not working on Linux 32 too (on both 0.98 and 1.0)
++
David
-
Re
Try with this new version
http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/select_by_objtype.html
++
David
-
Already tried and it works.
Special thanks, again!
-
Anywhere within your script, add this line...
CamBamConfig.Defaults.ReloadTreeAfterScript = false
Normally, after a script has finished executing some code is run to reload the drawing tree view (in case the script has changed anything within the drawing).
ReloadTreeAfterScript = false will prevent this happening, so your selections will stay in place.
I also notice the 'after script' code also does a view.RefreshView(), so you could also leave out that line in your script.
The ReloadTreeAfterScript property is not saved in the configuration file, so the next time CamBam is restarted it's value will revert back to 'True'.
Sorry about that one! :-[
Change this line...
view.Select(newselection.ToArray())
to
view.Select(newselection.ToArray(GetType(Entity)))
OR,
you can change
dim newselection as ArrayList = new ArrayList()
to
dim newselection as Generic.List(of Entity) = new Generic.List(of Entity)()
but not both! ;)
Alleluia! :)
I knew I've seen a clue how to make a selection editable after a script is used to select objects by some criteria.
Took me half a day of searching though.
Now, if someone can show me how those lists of entity are initialized in Python ... ::)
-
Hello
We also talk about this a few month ago here
https://cambamcnc.com/forum/index.php?topic=8488.msg67361#msg67361
But I've no idea for the python syntax ... sorry.
I'll add this tips to the snippet page ;) it can be useful for others ;)
++
David