Author Topic: How can I get my macro to Select all the items the macro just drew?  (Read 338 times)

jacklward

  • Newbie
  • *
  • Posts: 36
My macro draws a box, a line and 3 text items.
When it is done I would like all of those items it just drew to all be selected not just the last one.
Any help would be appreciated.

Here is my solution thanks to Lar...

Sys(80) = 0 ' unselect all entities

For sNumber = Sys(9) to Sys(9) - 4 Step -1 ' selects last 5 entities drawn
      GETATTR sNumber, sType, sSelect
      PUTATTR sNumber, sType, 1 ' 0xSelect, 1Select
   Next sNumber

' 2 Select Previous commands same as Regen but without redrawing the entire screen
>SelectPrevious
{
}
>SelectPrevious
{
}
« Last Edit: May 28, 2018, 06:37:37 AM by jacklward »

JJG

  • Hero Member
  • *****
  • Posts: 735
Hy,

the tricks is to draw all your entities in a special "working"-layer, then, when finished, select the working layer and change it to the desired layer.
 ;)

Pearco

  • Hero Member
  • *****
  • Posts: 858
Hi guys;

I don't use the filter commands, but could you select all through the filter and group it or what ever your end goal is?

Jim
User since ProDesign 1.5

Lar

  • Hero Member
  • *****
  • Posts: 2818

Somewhere above where the macro draws stuff put:
sys9=sys(9)


After the macro draws stuff put:
Code: [Select]
'SELECT LAST ENTITIES...
for sel=sys9+1 to sys(9)
GETATTR sel, typee, selectt, la, groupp, redd, greenn, bluee, solidd
selectt=1
PUTATTR sel, typee, selectt,    'the rest of the stuff is not necessary unless you want to use them somehow...
next


Lar

jacklward

  • Newbie
  • *
  • Posts: 36
Lar,

Thanks, I understand your code, it should work but it didn't, nothing shows on the screen as being selected.

Attached is the code, please try it.

Jack

Lar

  • Hero Member
  • *****
  • Posts: 2818

Add a regen at the end of the macro (maybe they are selected but the screen isn't showng so).

If that doesn't work make sure the layers aren't locked or something


update: yep, I ran your code and it needed a regen. I actually thought about that after posting my code but I said you would figure it out  :)


Lar
« Last Edit: May 27, 2018, 04:28:09 PM by Lar »

jacklward

  • Newbie
  • *
  • Posts: 36
Lar,

Thanks that worked, but I didn't want to redraw the whole drawing so I came up with this...

I put Sys(80) = 0 (to clear any existing selection) before your ' SELECT LAST ENTITIES... code and this after it...

>SelectPrevious
{
}
>SelectPrevious
{
}

This avoids the tedious redraw if I am zoomed out on the drawing.

Again thanks for your help.

Jack

jacklward

  • Newbie
  • *
  • Posts: 36
For my SOLUTION, thanks to Lar, see the original post.

Lar

  • Hero Member
  • *****
  • Posts: 2818

Yep, I see what you did and I thought about that way after I downloaded and read your macro, ie, since the last thing the macro does is always draw the 3 objects, you don't need to remember sys(9) before their creations, just count 3 backward from sys(9) at the end of the macro.

My macros usually do stuff based on some random amount (such as how many entities are selected) so I code as generic as possible.
You could also put the getattr/sel/putattr code, each with sys(9),right after each creation since, unless the macro does something to deselect stuff, or 'select when created' is on, the selected stuff will remain selected when you create and select the next item. For this the macro should turn off  'select when created' (ie, test see if it's on and turn it off... at end: if it was on then turn it back on).


You could also use query/change/update to select stuff.




Lar
« Last Edit: May 28, 2018, 06:37:12 PM by Lar »