about number of handle(s) of a selection ...

Started by JJG, January 12, 2009, 04:19:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JJG

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

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

#2
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 !

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.

JJG

#4
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.

prl

#5
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

JJG

Bravo ! i take my hat off to you !!!
Thanks a lot !

JJG

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

just to complete this topic, the first idea of prl :
Quote from: prl 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.
does not operate as he mind :

select something with 3 handles, and run this macro :

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

#9
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 :'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.

prl

JJG, very nice basiccad workaround solution!   ;)

bdeck

#11
Prl and JJG,

Very cool.

Thanks for the contributions.

BD