A
AbdUllah Muhammad
Guest
I created 2 procedures in SKILL
The first takes 2 points "for ex: list(x:y)" and take a list of points returned by the command blockage_id~>points, and tries to find if those 2 points found on the returned list..
findPointsInList(pt1 pt2 ptList) .. returns 1 if successful or 0 otherwise
The second procedure uses the first one in its "if" condition, but it doesn't work, which is illogical to me!!
Hint: the many println() usages is for debugging.
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Globals
deltaX = 0.02
deltaY = 0.02
offset = 0.02
cutWidth = 0.16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure( updateBlockage(id pts)
prog(
(
list1 list2 list3 list4 x1 y1 x2 y2 x3 y3 x4 y4 rectId idBlkgMetal1 blkgPointList vartop varbottom
x3TopBlkg y3TopBlkg x33TopBlkg y33TopBlkg x4TopBlkg y4TopBlkg x44TopBlkg y44TopBlkg
)
vartop = 0
varbottom = 0
list1 = list()
list2 = list()
list3 = list()
list4 = list()
blkgPointList = list()
arr=listToVector(pts)
list1 = arr[0]
list2 = arr[1]
list3 = arr[2]
list4 = arr[3]
pts=vectorToList(arr)
x1 = car(list1)
y1 = car(cdr(list1))
x2 = car(list2)
y2 = car(cdr(list2))
x3 = car(list3)
y3 = car(cdr(list3))
x4 = car(list4)
y4 = car(cdr(list4))
idBlkgMetal1 = id
blkgPointList = idBlkgMetal1~>points
;;;;;;;;;;;;;;
;Top blockage;
;;;;;;;;;;;;;;
x3TopBlkg = x3 + deltaX
y3TopBlkg = y3 + deltaY
x4TopBlkg = x4 - deltaX
y4TopBlkg = y4 + deltaY
x33TopBlkg = x3TopBlkg + offset
y33TopBlkg = y3TopBlkg + cutWidth
x44TopBlkg = x4TopBlkg - offset
y44TopBlkg = y4TopBlkg + cutWidth
;println("x3TopBlkg=")
;println(x3TopBlkg)
;println("y3TopBlkg=")
;println(y3TopBlkg)
;println("x4TopBlkg=")
;println(x4TopBlkg)
;println("y4TopBlkg=")
;println(y4TopBlkg)
;println("==========")
;;Top Blockage
vartop = findPointsInList(list(x3TopBlkg y3TopBlkg) list(x4TopBlkg y4TopBlkg) blkgPointList)
println("vartop = ")
println(vartop)
when( equal( vartop 1 )
println("Hi from top!")
leChopShape( idBlkgMetal1 list(x33TopBlkg:y2 x33TopBlkg:y33TopBlkg x44TopBlkg:y44TopBlkg x44TopBlkg:y1) t t 10 )
procedure(myFilterProc(objId)
if(objId~>objType=="rect" t nil)
)
rectId = gePointQuery( hiGetCurrentWindow() x3:y3 "myFilterProc")
leStretchShape( rectId list( 0 cutWidth )
list(nil t t nil) t )
leStretchShape( rectId list(offset 0)
list(nil nil t t) t )
leStretchShape( rectId list(-offset 0)
list(t t nil nil) t )
);when
);prog
);proc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure( findPointsInList(pt1 pt2 ptList)
prog( (pt1found pt2found flag1 flag2 sum cond1 cond2 cond3 cond4 cond5 cond6)
sum = 0
pt1found = 0
pt2found = 0
flag1 = 1
flag2 = 1
cond1 = 0
cond2 = 0
cond3 = 0
cond4 = 0
cond5 = 0
cond6 = 0
;println("pt1found =")
;println(pt1found)
;println("pt2found =")
;println(pt2found)
;println("sum =")
;println(sum)
foreach( pt ptList
;println("pt =")
;println(pt)
;println("pt1")
;println(pt1)
cond1 = equal(flag1 1)
cond2 = equal(float(car(pt)) float(car(pt1)))
cond3 = equal(float(car(cdr(pt))) float(car(cdr(pt1))))
cond4 = equal(flag2 1)
cond5 = equal(float(car(pt)) float(car(pt2)))
cond6 = equal(float(car(cdr(pt))) float(car(cdr(pt2))))
;println("Blkg pt")
;println(pt)
;println("pt1 ")
;println(pt1)
;println("pt2")
;println(pt2)
;println(cond1)
;println(cond2)
;println(cond3)
;println(cond4)
;println(cond5)
;println(cond6)
;println("=========")
when( cond1 && cond2 && cond3
;println("I am section 1!")
pt1found = 1
flag1 = 0
);
when( cond4 && cond5 && cond6
;println("I am section 2!")
pt2found = 1
flag2 = 0
);when4
);foreach
sum = pt1found + pt2found
;println("after evaluation:")
;println("pt1found =")
;println(pt1found)
;println("pt2found =")
;println(pt2found)
;println("sum =")
;println(sum)
if( equal( sum 2) then
return(1)
else
return(0)
);if
);prog
);proc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I hope someone helps me.
Thank you!
Abdullah
The first takes 2 points "for ex: list(x:y)" and take a list of points returned by the command blockage_id~>points, and tries to find if those 2 points found on the returned list..
findPointsInList(pt1 pt2 ptList) .. returns 1 if successful or 0 otherwise
The second procedure uses the first one in its "if" condition, but it doesn't work, which is illogical to me!!
Hint: the many println() usages is for debugging.
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Globals
deltaX = 0.02
deltaY = 0.02
offset = 0.02
cutWidth = 0.16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure( updateBlockage(id pts)
prog(
(
list1 list2 list3 list4 x1 y1 x2 y2 x3 y3 x4 y4 rectId idBlkgMetal1 blkgPointList vartop varbottom
x3TopBlkg y3TopBlkg x33TopBlkg y33TopBlkg x4TopBlkg y4TopBlkg x44TopBlkg y44TopBlkg
)
vartop = 0
varbottom = 0
list1 = list()
list2 = list()
list3 = list()
list4 = list()
blkgPointList = list()
arr=listToVector(pts)
list1 = arr[0]
list2 = arr[1]
list3 = arr[2]
list4 = arr[3]
pts=vectorToList(arr)
x1 = car(list1)
y1 = car(cdr(list1))
x2 = car(list2)
y2 = car(cdr(list2))
x3 = car(list3)
y3 = car(cdr(list3))
x4 = car(list4)
y4 = car(cdr(list4))
idBlkgMetal1 = id
blkgPointList = idBlkgMetal1~>points
;;;;;;;;;;;;;;
;Top blockage;
;;;;;;;;;;;;;;
x3TopBlkg = x3 + deltaX
y3TopBlkg = y3 + deltaY
x4TopBlkg = x4 - deltaX
y4TopBlkg = y4 + deltaY
x33TopBlkg = x3TopBlkg + offset
y33TopBlkg = y3TopBlkg + cutWidth
x44TopBlkg = x4TopBlkg - offset
y44TopBlkg = y4TopBlkg + cutWidth
;println("x3TopBlkg=")
;println(x3TopBlkg)
;println("y3TopBlkg=")
;println(y3TopBlkg)
;println("x4TopBlkg=")
;println(x4TopBlkg)
;println("y4TopBlkg=")
;println(y4TopBlkg)
;println("==========")
;;Top Blockage
vartop = findPointsInList(list(x3TopBlkg y3TopBlkg) list(x4TopBlkg y4TopBlkg) blkgPointList)
println("vartop = ")
println(vartop)
when( equal( vartop 1 )
println("Hi from top!")
leChopShape( idBlkgMetal1 list(x33TopBlkg:y2 x33TopBlkg:y33TopBlkg x44TopBlkg:y44TopBlkg x44TopBlkg:y1) t t 10 )
procedure(myFilterProc(objId)
if(objId~>objType=="rect" t nil)
)
rectId = gePointQuery( hiGetCurrentWindow() x3:y3 "myFilterProc")
leStretchShape( rectId list( 0 cutWidth )
list(nil t t nil) t )
leStretchShape( rectId list(offset 0)
list(nil nil t t) t )
leStretchShape( rectId list(-offset 0)
list(t t nil nil) t )
);when
);prog
);proc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure( findPointsInList(pt1 pt2 ptList)
prog( (pt1found pt2found flag1 flag2 sum cond1 cond2 cond3 cond4 cond5 cond6)
sum = 0
pt1found = 0
pt2found = 0
flag1 = 1
flag2 = 1
cond1 = 0
cond2 = 0
cond3 = 0
cond4 = 0
cond5 = 0
cond6 = 0
;println("pt1found =")
;println(pt1found)
;println("pt2found =")
;println(pt2found)
;println("sum =")
;println(sum)
foreach( pt ptList
;println("pt =")
;println(pt)
;println("pt1")
;println(pt1)
cond1 = equal(flag1 1)
cond2 = equal(float(car(pt)) float(car(pt1)))
cond3 = equal(float(car(cdr(pt))) float(car(cdr(pt1))))
cond4 = equal(flag2 1)
cond5 = equal(float(car(pt)) float(car(pt2)))
cond6 = equal(float(car(cdr(pt))) float(car(cdr(pt2))))
;println("Blkg pt")
;println(pt)
;println("pt1 ")
;println(pt1)
;println("pt2")
;println(pt2)
;println(cond1)
;println(cond2)
;println(cond3)
;println(cond4)
;println(cond5)
;println(cond6)
;println("=========")
when( cond1 && cond2 && cond3
;println("I am section 1!")
pt1found = 1
flag1 = 0
);
when( cond4 && cond5 && cond6
;println("I am section 2!")
pt2found = 1
flag2 = 0
);when4
);foreach
sum = pt1found + pt2found
;println("after evaluation:")
;println("pt1found =")
;println(pt1found)
;println("pt2found =")
;println(pt2found)
;println("sum =")
;println(sum)
if( equal( sum 2) then
return(1)
else
return(0)
);if
);prog
);proc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I hope someone helps me.
Thank you!
Abdullah