Author Topic: about number of handle(s) of a selection ...  (Read 5743 times)

JJG

  • Hero Member
  • *****
  • Posts: 720
about number of handle(s) of a selection ...
« on: January 12, 2009, 04:19:19 AM »
hello,

for the macro, is there a sys-function or a way to know how many handle(s) a selection has ?

Thank's in advance !

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: about number of handle(s) of a selection ...
« Reply #1 on: January 12, 2009, 10:53:48 AM »
Looking through the macro17.hlp file, I didn't find one.  Depending on what your code is doing, you could seed the below sys values with some fake numbers and after the user has set some handles you could check to see which ones changed thereby giving you the handles count.

sys(190) = x1
sys(191) = y1
sys(202) = z1

sys(192) = x1
sys(193) = y2
sys(203) = z2

sys(194) = x3
sys(195) = y3
sys(204) = z3

JJG

  • Hero Member
  • *****
  • Posts: 720
Re: about number of handle(s) of a selection ...
« Reply #2 on: January 12, 2009, 11:28:03 AM »
Thanks, but i know already theses sys-functions, and there is values in the sys-functions for the 2nd and 3rd points even there is just one point of reference ... the buffer for 2nd and 3rd point is not updated.
Also you can not known if there is just one, or two or three ref.-point(s) for the selection by this way.

That's why i'm asking help for !
« Last Edit: January 12, 2009, 11:29:48 AM by JJG »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: about number of handle(s) of a selection ...
« Reply #3 on: January 12, 2009, 11:52:54 AM »
As I mentioned, you could put fake values in the sys functions and then check to see if they have changed.  I don't know of another solution.

JJG

  • Hero Member
  • *****
  • Posts: 720
Re: about number of handle(s) of a selection ...
« Reply #4 on: January 12, 2009, 11:59:11 AM »
Yes, thank's, i would try it ...

but imagine too, you need to kown at the begining of the macro how many handle(s) have the selection, before doing something that would require necessary 2 or 3 handles, for exemple, you can not checking that with sys(190 to 195 and 202 to 204) ... because they do not change before doing what you want to do.
and the precaution sys(80)>=1 is not enough ...

Also, it's necessary to find a good way to check how many handle(s) the selection do have.
« Last Edit: January 12, 2009, 12:16:05 PM by JJG »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: about number of handle(s) of a selection ...
« Reply #5 on: January 12, 2009, 12:55:11 PM »
I was looking through the OLE SDK and one can obtain it there.  I made a basiccad helper executable. It is in the attached zip file.  Maybe this will do what you need.

The below basiccad program gives an example of how to use it.  Note the executable returns a string value to the windows clipboard.  Only way I could make the routine generic without having to recompile for each DesignCAD version.

'nhandles.d3m  (determines number of handles set for a selection set)

' notes - uses an OLE helper program, nhandles.exe, which returns the number of handles set as a
'         windows clipboard text string.

'         should work with version 15.3, 17.2, 18.2 and 19.0

run "nhandles.exe", 2

precision 0
nhandles = sys$(40)

Message nhandles, "handle(s) set"

End
« Last Edit: January 12, 2009, 01:10:43 PM by prl »

JJG

  • Hero Member
  • *****
  • Posts: 720
Re: about number of handle(s) of a selection ...
« Reply #6 on: January 12, 2009, 02:24:04 PM »
Bravo ! i take my hat off to you !!!
Thanks a lot !

JJG

  • Hero Member
  • *****
  • Posts: 720
Re: about number of handle(s) of a selection ...
« Reply #7 on: January 12, 2009, 02:38:41 PM »
I think too, there is a function integrated in Designcad-language, to do that ... may be that possible, in the future, to have a sys-function or anything else who give directly that (equivalent "nhandles") in macro-language ?

JJG

  • Hero Member
  • *****
  • Posts: 720
Re: about number of handle(s) of a selection ...
« Reply #8 on: January 13, 2009, 10:34:53 PM »
just to complete this topic, the first idea of prl :
As I mentioned, you could put fake values in the sys functions and then check to see if they have changed.  I don't know of another solution.
does not operate as he mind :

select something with 3 handles, and run this macro :

Code: [Select]
If sys(80)<1 then goto fin

sys(996) = 1 'Enhanced Esc Key Behavior

Sx=sys(190)  'Selection Handle 1 X value [-10e6<=x<=10e6]
Sy=sys(191)  'Selection Handle 1 Y value [-10e6<=x<=10e6]
Sz=sys(202)  'Selection Handle 1 Z value [-10e6<=x<=10e6]
Tx=sys(192)  'Selection Handle 2 X value [-10e6<=x<=10e6]
Ty=sys(193)  'Selection Handle 2 Y value [-10e6<=x<=10e6]
Tz=sys(203)  'Selection Handle 2 Z value [-10e6<=x<=10e6]
Ux=sys(194)  'Selection Handle 3 X value [-10e6<=x<=10e6]
Uy=sys(195)  'Selection Handle 3 Y value [-10e6<=x<=10e6]
Uz=sys(204)  'Selection Handle 3 Z value [-10e6<=x<=10e6]

Message "sys(190)= ", sys(190), chr$(13), "sys(192)= ", sys(192), chr$(13), "sys(194) =  ", sys(194)

Sys(80)=0

sys(190)=10
sys(192)=100
sys(194)=1000 

Message "sys(190)= ", sys(190), chr$(13), "sys(192)= ", sys(192), chr$(13), "sys(194) =  ", sys(194)

>SelectPrevious
{
}

Message "sys(190)= ", sys(190), chr$(13), "sys(192)= ", sys(192), chr$(13), "sys(194) =  ", sys(194)

end.

fin:
inf$="Select something and try again !"
message inf$
End
try it again with a one handle selection : the buffer for 2nd and 3rd point is not updated, and even more designcad assign theses values for a one handle-selection, and remember them ... !
That's why i was answering "Also you can not known if there is just one, or two or three ref.-point(s) for the selection by this way."

On the other hand, the macro through the OLE SDK from prl works very well.

JJG

  • Hero Member
  • *****
  • Posts: 720
Re: about number of handle(s) of a selection ...
« Reply #9 on: January 14, 2009, 03:48:45 AM »
O.K.  I finaly find the solution with macro-commands : Designcad can not update fake value (for theses handles coordonates sys-functions), but he can update his propers values ... also i minded to move the selection, read the new values, and see which ones changed, and of course move the selection to his previous position. By this way, it's possible to know the number of handle(s) of the selection.

Also the macro become :
Code: [Select]
'Analysis of n_handels

If sys(80)<1 then goto fin

sys(996) = 1 'Enhanced Esc Key Behavior
sys(36)=2 'super silent mode

Sx=sys(190)  'Selection Handle 1 X value [-10e6<=x<=10e6]
Sy=sys(191)  'Selection Handle 1 Y value [-10e6<=x<=10e6]
Sz=sys(202)  'Selection Handle 1 Z value [-10e6<=x<=10e6]
Tx=sys(192)  'Selection Handle 2 X value [-10e6<=x<=10e6]
Ty=sys(193)  'Selection Handle 2 Y value [-10e6<=x<=10e6]
Tz=sys(203)  'Selection Handle 2 Z value [-10e6<=x<=10e6]
Ux=sys(194)  'Selection Handle 3 X value [-10e6<=x<=10e6]
Uy=sys(195)  'Selection Handle 3 Y value [-10e6<=x<=10e6]
Uz=sys(204)  'Selection Handle 3 Z value [-10e6<=x<=10e6]

'mes$="sys(190)=", sys(190), chr$(13), "Tx=", Tx, chr$(13), "Ux=", Ux
'message mes$

>SelectMove
{
  <Pointxyz [Sx-10,Sy-10,Sz-10]
  }

Ax=sys(192)  'moved Selection Handle 2 X value
Bx=sys(194)  'moved Selection Handle 3 X value

'mes$="sys(190)=", sys(190), chr$(13), "Ax=", Ax, chr$(13), "Bx=", Bx
'message mes$

>SelectMove
{
  <PointXYZ [Sx,Sy,Sz]
  }

sys(36)=0 'super silent mode off

if Ux=Bx and Tx=Ax then
message "nHandles = 1 "
else
if Tx<>Ax and Ux=Bx then
message "nHandles = 2 "
else
message "nHandles = 3 "
end if
end if

end.

fin:
End


and work properly.
« Last Edit: January 14, 2009, 05:53:50 AM by JJG »

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: about number of handle(s) of a selection ...
« Reply #10 on: January 14, 2009, 05:17:20 AM »
JJG, very nice basiccad workaround solution!   ;)

bdeck

  • Hero Member
  • *****
  • Posts: 827
Re: about number of handle(s) of a selection ...
« Reply #11 on: January 14, 2009, 07:44:53 PM »
Prl and JJG,

Very cool.

Thanks for the contributions.

BD
« Last Edit: July 01, 2009, 06:29:05 PM by bdeck »