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.

Highspeed select, move , duplicate macros

Started by bdeck, February 25, 2007, 09:24:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bdeck

Copied from the old Upperspace forum:

Improved Versions of N, M, and S macros, similar to those in DC version 6:

Posted below is a zip file containing 3 essential macros that make using DC easier and faster

All 3 macros work in preset point mode or in default mode.

The syntax for using the macros is documented in the macro text file itself.

N and M allow copying or moving any selected entities to any position and alignment with 2 or 4 mouse clicks, as in DC version 6.

They operate completely differently from the Move and Duplicate commands in the DC edit menu, in that they do not use preset selection handles.

I've recently updated the macros to correct a minor bug in DesignCad's internal Duplicate and Move commands which causes an error if a 180 degree rotation is attempted by simply swapping the position of 2 control points.

The S command is an improved select command that OR's together any selected areas or entities. It corrects DesignCad's standard XOR method, which deselects overlapping selection areas. The S macro also hides the selection handles so that they are not in the way on the screen. DC's select function still works as a select/deselect tool, and you can use either select method at any time.

These are written for 2D or 3D, but I use mostly 2D. If they need improvement for 3D, please post improvements here.

BD


Edit: Note that original post has been replaced with most recent version 11/09/08

bdeck

#1
I see that DesignCad Version 18.2 has fixed the prior bug in DC that caused a positioning error whenever a 4-point move or duplication called for a 180 degree rotation.  (Thanks, DT.)

Prior versions of N and M macros accounted for that error by making 4-point moves and duplicates in 2 steps. This worked fine, but required multiple step undo.

The new versions of N and M macros posted here first check the DC version number, and perform single step moves and dups in version 18.2+.


bdeck

#2
Dempsey has pointed out that sys(80) and getselect fail to report all entity types.

See http://forum.designcad.com/index.php?topic=1535.0

Below is an update to the or-select macro, corrected to  account for the sys(80) limitations.


BD

(Included in current zip file posted above.)

' s.d3m   version 0.7  bdeck 8/08
' OR select function
' Modified select function emulates most of DC6 select functionality.
' Works in or out of preset point mode.
'
' Changes selection logic of overlapping areas from XOR to OR.
'
' Version 7 corrects bug caused by limitations of sys(80) and getselect (thanks to Dempsey for the heads up)
'
' Syntax execute, pt, pt.... pt, enter (1, 3 or more select)
' pt, pt ... pt execute (multi select)
' pt, pt, execute (rect area select)
' execute pt, pt, enter (rect area select)


Sys(41) = 0
n=sys(1)
ns80=sys(80)

if n=0 then
   setpoint "Select (Set a point)" 99 'set 1 to 98 points
   n=sys(1)
   if n=0 then end
   if n>98 then end ' too many points
endif
sflag=sys(36)
sys(36)=1 ' hide mouse, dialog boxes

if n=2 then 'area select

    ns=0
    ne=sys(9)
    dim entsel(ne+1)
    for i=1 to ne
       getattr i,t,entsel(i)   ' archive current selection set
       ns=ns+entsel(i)
    next i

  >DeSelect  'necessary because Type 1 is broken in DragSelect in DC14
  {
  }

  >DragSelect
  {
     <Type 1
     pointval x y z 1
     <Pointxyz [x,y,z]
      pointval x y z 2
     <Pointxyz [x,y,z]
  }

  if ns>0 then
     For i = 1 To ne 'Reselect all prior selected items
      if entsel(i) then
         Getattr i, type
         Putattr i, type, entsel(i)
      endif
    Next i
  endif

else 'multi point select
  for i=1 to n
    ns2=sys(80)
    >PointSelect
    {
      <Type 1 ' [0 = normal, 1 = Shift, 2 = Ctrl, 3 = Ctrl+Shift]
      pointval x y z i
      <Pointxyz [x, y, z]
    }
    if sys(80)<ns2 then 'reselect last selected item if inadvertently deselected
      >PointSelect
      {
        <Type 1
        pointval x y z i
        <Pointxyz [x, y, z]
      }
    endif
next i
endif

CLEANUP: 'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

if (sys(80)>ns80) then ' if new handles move them off the screen (optional)
  >SetHandle
  {
     <Pointxyz [sys(600)-10,sys(602)-10,0]
  }
endif

sys(36)=sflag  'restore mouse, dialog boxes
sys(1)=0 ' clean up stray points

REGEN

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end Cleanup

bdeck

#3
An additional undocumeneted feature Dempsey uncovered is that the select parameter of getattr is really a bitwise combination of the current selection flag value and the prior selection flag value.

This version is modified to use modulo arithmetic to properly decode the select value.

2-point area select of all prior versions is potentially buggy. 

Note that any selection or deselection performed in basiccad prevents subsequent use of SelectPrevious.


EDIT: Flaky NOT logic corrected 9/5/08, here and in lead post.


'  s.d3m   version 0.8  bdeck 9/08
' OR select function
' Modified select function emulates most of DC6 select functionality.
' Works in or out of preset point mode.
'
' Changes selection logic of overlapping areas from XOR to OR.
'
' Version .7 corrects bug in sys(80) and getselect (thanks to Dempsey for heads up)
' Version .8 adds pseudo bit logic to coorrect for undocumented DC prior selection flag.
' Note: does not reset prior selection flag, so selectprevious is nonfunctional after this macro.           
'
' Syntax
' execute, pt, pt.... pt, enter (1, 3 or more select)
' pt, pt ... pt execute (multi select)
' pt, pt, execute (2-pt area select)
' execute pt, pt, enter (2-pt area select)
 
Sys(41) = 0
n=sys(1)
ns80=sys(80)

if n=0 then
   setpoint "Select (one or more points)" 99 'set 1 to 98 points
   n=sys(1)
   if n=0 then end
   if n>98 then end ' too many points
endif
sflag=sys(36)
sys(36)=2              ' hide mouse, dialog boxes  2= suppress redraw (undocumented)

if n=2 then 'area select
  gosub archive
  if sys(345) then
    >DeSelect                'Deselect or turn off pointselect mode to assure that dragselect works correctly.
    {
    } 
  endif
>DragSelect              ' Will not select entities in point select mode if any entities are already selected
  {
     <Type 1             
      pointval x y z 1
     <Pointxyz [x,y,z]
      pointval x y z 2
     <Pointxyz [x,y,z]
   } 
   gosub resel

else 'multi point select
  for i=1 to n
    ns2=sys(80)
    >PointSelect
    {
      <Type 1 ' [0 = normal, 1 = Shift, 2 = Ctrl, 3 = Ctrl+Shift]
      pointval x y z i
      <Pointxyz [x, y, z]
    }
    if sys(80)<ns2 then 'reselect last selected item if inadvertently deselected
      >PointSelect
      {
        <Type 1
        pointval x y z i
        <Pointxyz [x, y, z]
      }
    endif
next i
endif

CLEANUP: 'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

if (sys(80)>ns80) then ' if new handles move them off the screen (optional)
  >SetHandle
  {
     <Pointxyz [sys(600)-10,sys(602)-10,0]
  }
endif

sys(36)=sflag  'restore mouse, dialog boxes
sys(1)=0 ' clean up stray points

REGEN

' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end Cleanup

end

archive:      '  archive current selection set, necessary becaurs type 1 dragselect uses XOR logic rather than OR logic
   ns=0
    ne=sys(9)
    dim entsel(ne+1)
    for i=1 to ne
       getattr i,t,sel
       entsel(i) = sel mod 2  ' nearest thing to a bitwise (AND 1) available in DC
       ns=ns+entsel(i)
    next i

return

resel:
     if ns>0 then
     For i = 1 To ne   'Reselect all prior selected items
         if entsel(i) then
              Getattr i, type, sel
               if  sel <> 1 then  Putattr i, type, 1                ' eliminate prior selection flag for all selected ents  
          endif
     Next i
    endif
return


Rob S


Shouldn't you, like, apply for the job of programming DC in the first place??

That way, you wouldn't have to figure this stuff out one bit at a time!!  ;D
User since forever

bdeck

#5
Oops,

One of my too-clever edits used improper NOT logic in an irrational attempt to shave a few microseconds from execution time.

If your version has a NOT operator, the error is corrected above.



BD



PS:

RobS, I guess I'll unpack my snowshoes.