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.

How can I move solids from within a macro?

Started by Dempsey, August 16, 2008, 07:32:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dempsey

Thanks bdeck and DT. That was the missing link. I got it working now.

Setting a handle, even if you do not use it, defeats the whole purpose of using "move by reference" in order to preserve original handles. Having not really used handles myself, how important is it to preserve the original handles?

If I make successive selections of solids using PUTATTR and for each solid I set a handle, this is going to add up. Where are all those handles stored?

Dempsey

Dempsey

I still like to hear comments on my previous reply, but in the meantime I have my first version of the "push apart" macro. Attached is the macro and one of my test drawings. Works for (multi-level) groups, solids, and individual entities. The drawing also includes text and dimensions examples, however the macro is not really intended for moving those, but it still works.

Future plans:

  • Currently I use the center of an object to push it apart. I like to add an option to use the "outside" surface center.
  • Currently only positive expansion values or percentages make sense. I like to allow negative values as well such that a -25% expansion reverses a previous +25% expansion.
  • Still considering to add a "restore" point (as DT suggested) as undoing the push apart operation can be very tedious requiring two UNDOs per "moved" object.
  • I have not yet tested the macro with blocks and symbols.
  • I have not tested the macro with V15.3 or V16.3

Appreciate any comments and suggestions. And thanks for all the help guys. It was a good learning experience and I am now much more comfortable with BasicCAD.
Dempsey

prl

Dempsey, thanks.  I've downloaded it and will take a look at it over the next few days.  Also thank you for the small test drawing (currently using modem at 14.4 provided a hummingbird doesn't land on the phone line.) :D

prl

Dempsey, I like looking over your code.  Wish more would share, one gets ideas for this and that.

Explain to me your thoughts regarding the "pull apart" hierarchy you intend.  If I select the entire sample file model and use "C" , "XYZ" and 10%, the model explodes in groups which is neat.

But if I select a single group, it doesn't appear to pull apart. I expected it to default to within the group level which in this case is the solids level.  But if I manually explode the group, the routine does in fact a nice job pushing/pulling apart a solids assembly.



Dempsey

prl, the macro works on selectable objects. A group is one selectable object and hence moved as a whole. If you like to push apart the objects within a group you have (like you did already) to explode the group, run the macro, and do a group define again.

Of course pushing apart the objects within a group, if only one group is selected, is possible, but then the issue becomes what to do in case of a multi-level group.

Appreciate you feedback.
Dempsey

bdeck

#35
Quote from: Dempsey on September 03, 2008, 06:21:17 PM
Setting a handle, even if you do not use it, defeats the whole purpose of using "move by reference" in order to preserve original handles.

Hi Dempsey,

I agree that setting a handle for a reference 1 move is silly.

It serves no purpose and can lead to errors.

Worse yet, as you appear to have noticed, a move by reference moves the selection handle to the final reference point. So if you had handles on your selection, whether you wanted them to move relative to the selection or stay put, either way you would be screwed unless the handle started at 0,0,0. 

One could archive sys(190), sys(191), and sys(202) and restore the handles when done.

But it seems easier to just use reference 0 moves.

An alternative move method that does not involve handles is to use change ent_point for each point in the selection.


Regards,

BD

Dempsey

Hi BD,

I am with you on the handles, but your alternate move method looks too much like open-heart surgery to me. ;D

Instead I might code a second push-apart macro using PointSelect instead of PUTATTR. When I use PointSelect it will cause the selection of an entire group or a solid or an entity, and I believe that I don't have to set a handle before the move. That is the first advantage.

The seconds advantage is that I don't have to make multiple passes through the selection list to process multi-level groups, and hence far less overhead when lots of objects are selected for the push-apart.
Dempsey

prl

#37
Dempsey, your "push/pull" basiccad is a nice addition to every 3d modeler's toolbox.  I'm going to modify it a bit so that if your selection set consists of groups and solids it uses the following default behavior.


1.  Automatically create a temporary drawing for the push/pull operations (original model is never touched),

2.  If more than one group is selected - default action is to push/pull by groups,

3.  If only one group is selected - default action is to push/pull by solids within the single group.


I'll only check the simple group index value. I don't use nested groups and regularly sweep out all type 34 entities anyway. The simple groups can use the same logic as the solids Id index.

I'll post my version when it works.


Dempsey

prl, sounds good. Do you like to wait until I have my version of using PointSelect instead of PUTATTR as it might be faster? If so then you will have to give me a few days.
Dempsey

Dempsey

#39
I have been working on a new version of the PushApart.d3m where I use >PointSelect instead of PutAttr.

My new macro (with >PointSelect) is attached and works fine on a new drawing with solids, but after I have used the old macro (with PutAttr) on the drawing the new macro does not work properly anymore.

DT wrote earlier in this topic:
Quote
Essentially, the PutAttr statement doesn't create a selection handle when you use it to select one or more entities. So yes, you need to manually set a selection handle if you're going to move or copy objects.
Statements don't usually have the full range of "visual" effects that the commands do.

The funny thing is that when I put a >SetHandle before the >Move in my new macro it works always fine.

Here I am trying desperately to avoid setting handles in order to cut the undo list by 50%, and now it appears that commands used from within a macro need the handles too.

Any ideas why this is?
Dempsey

prl

#40
Quote from: Dempsey on September 16, 2008, 08:53:22 PM
Here I am trying desperately to avoid setting handles in order to cut the undo list by 50%, and now it appears that commands used from

Dempsey, I haven't explored the following too deeply but initially it seems to work on your original pushapart macro, the one with getattr/putattr.  I removed the >sethandles code and also switched to >dragmove rather than >move. My changes are in blue


Excerpt from pushapart.d3m
.
.
.
.
  IF ShowValues = 1 THEN
    PRINT "X from", PacX, "to", CtrX, "plus", DeltaX, "(", CtrX + DeltaX, ")"
    PRINT "Y from", PacY, "to", CtrY, "plus", DeltaY, "(", CtrY + DeltaY, ")"
    PRINT "Z from", PacZ, "to", CtrZ, "plus", DeltaZ, "(", CtrZ + DeltaZ, ")"
    PRINT "Any key to continue"
    ANYKEY
    WCLOSE
  END IF
 
  'Get coordinates of selection handle, even if garbage values
  OrgX = Sys(190)
  OrgY = Sys(191)
  OrgZ = Sys(202)
 
  >DragMove
  {
     <pointxyz [OrgX + DeltaX], [OrgY + DeltaY], [OrgZ + DeltaZ]
  }

 
RETURN

Dempsey

prl, you are dead on. Thanks so much.

Both the pushapart.d3m and pushapart2.d3m now work without setting extra handles. I will clean them both up a bit and then publish them for general use.
Dempsey

Dempsey

The final versions of both macros can be found on http://forum.designcad.com/index.php?topic=1582.0.

Thanks for all the help. It was a great learning experience.
Dempsey

Dr PR

#43
Dempsey,

I have been following this topic but recently work has caused a serious reduction of spare time so I haven't participated.

You haven't said (for those who haven't studied the code) what this macro is supposed to do (push-apart is pretty vague). Is the purpose to ceate an "exploded" drawing?

******

Sorry - I just found your post elsewhere on the forum.
DesignCAD user since 1987

Dempsey

Dr PR,

"Explode" a drawing would indeed be a better name, but "explode" is already used in DesignCAD for solids and groups and means something else. That is why I used the "push-apart" term.
Dempsey