DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Selecting and grouping

Started by Pearco, April 29, 2019, 02:23:30 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Pearco

I am writing a new macro that creates a 3D cabinet that I want to group just before exiting the macro so as to select the unit and place it. The selecting seams to work ok, but not grouped ready to move. Any ideas.

Thanks Jim

Pearco
Jim
User since ProDesign 1.5

Lar


After the selection code...


>GroupDefine
{
}




If that doesn't work I would have to see your code to see what's going on.(the last bit, including the selection).


Lar

Pearco

Hi Lar;

Thanks for the reply, but no luck. I wrote the file a while back and was just trying new things and cleaning up the code. This will be my first attempt to attach something.
Jim
User since ProDesign 1.5

bdeck

#3
Hi pearco,

Here are two simple examples that seem to work ok.

Edit: ( But I'm not certain why the macros deselect after grouping. )

DC requires a regen to show the selection status after a selection using "putattr" or "change".

bd

' ' gtest.d3m   test grouping of new entities selected using "change"

Alias ENT_SELECTED  &H010C 
ne0=sys(9)  ' initial number of entites

message  "draw two new lines"
>Line
{
<Incomplete
}

>Line
{
<Incomplete
}

ne=sys(9)

if ne>ne0 then
if sys(80)>0 then               ' optionally deselect any previously selected items, select

only new items
>deselect
{
}
endif

ne1=ne0+1
for n=ne1 to ne
entity n
change ENT_SELECTED, 1
update                                       
next n
>GroupDefine
{
}
      regen
endif
message  "two new lines are now grouped"
end


' 'gtest2   test grouping of new entities selected using "putattr"

ne0=sys(9)  ' remember initial number of entites
message  "draw two new lines"
>Line
{
<Incomplete
}

>Line
{
<Incomplete
}

ne=sys(9)

if ne>ne0 then
if sys(80)>0 then               ' optional - deselect any previously selected items, select only new items
>deselect
{
}
endif
ne1=ne0+1
for n=ne1 to ne               ' select all new entities
getattr n, t
putattr n, t, 1     'select the entity
next n
>GroupDefine
{
}
        regen
endif
message  "two new lines are now grouped"
end

bdeck

#4
Pearco,

If you use sys(242) to select more than one entity in a macro, that could cause a problem.

It turns out that DC deselects all previous selections when a new entity is drawn with sys(242) set.

Perhaps that is why I don't use sys(242).  Dunno, too old to remember.

As shown in the prior post,  I use "putattr" or "change" to select entities in macros.

bd


' 'gtest3   test grouping of new entities selected using sys(242)

ne0=sys(9) 'initial no of entities
sys242=sys(242) 'archive status of select on creation flag
sys(242)=1 

message  "draw two new lines"

>deselect 'optional - deselect any previously selected items
{
}

>Line
{
<Incomplete
}

>Line
{
<Incomplete
}

ne=sys(9)

if ne>ne0+1 then
>GroupDefine
{
}
endif
sys(242)=sys242    'restore status of flag
message  "Two new lines are NOT grouped because selection status does not persist between drawing commands with sys(242) set."
end

Lar

#5

Pearco,

Here's what I found (selecting and grouping part only):



>SelectDefine
{

  }

There is no SelectDefine command. You have to use GetAttr and PutAttr using the entity id with the help of sys(9). So either at the start of the macro you establish the value of sys(9) and count the number of entities created during the macro......   sys(9)+1

,sys(9)+2, etc....... Or after the macro creates the entities you use ......   sys(9) for the last entity created by the macro, sys(9)-1 for first to last, sys(9)-2for 2nd to last, etc..........


Note that GetAttr and PutAttr does not deselect what is already selecteded. This is good for selecting multiple entities but you would have to deselect anything that is already selected before the macro is run, using sys(80)=0 at the start of the macro.

'  >SetStrartPoint

Start is spelt wrong. You did have this commented out but in the next command, DragSelect, it looks like you did use the value of the start point, which may have caused the DragSelect the select where nothing is.




>DragSelect
  {
   <PointXYZ 0,0,0
   <PointXYZ [0],[FFH],[11.75]

  }
<PointXYZ [FFH],[11.75] didn't work for me <<maybe because of my comments above, ie, it selected where nothing is>>. I just removed the two PointXYZ's so I could drag select manually to continue testing the macro.



End

This came before the Group Define so the macro stopped there. I don't know if you did that as a test and forgot to remove it.



>GroupDefine
  {
  }

When I fixed all the above stuff the GroupDefine worked (I didn't put in the GetAttr and PutAttr, I just removed the SelectDefine in order for the macro to run then did a manual select using the DragSelect with no points).


Lar

Pearco

Thanks Lar and bdeck for your input.
The grouping and selecting was more of an experiment than a need. Moving the origin was done to keep the new cabinet in a screen corner where I would group and move it manually with out selecting any of the existing ones. So I just cleaned up the code and now I don't have to remember to set the origin before running the macro. Now I will mess it up trying to put attributes on each component part for a material list. That will burn some brain cells. Again thanks for your help.
Jim
User since ProDesign 1.5