exporting S, SS, EPC, and beacons data
This commit is contained in:
parent
f617250d12
commit
deaaf26840
219
generate_csv.lsp
219
generate_csv.lsp
@ -45,7 +45,6 @@
|
|||||||
(defun getDynPropVal (blk propName / props p n raw v)
|
(defun getDynPropVal (blk propName / props p n raw v)
|
||||||
(setq propName (strcase propName))
|
(setq propName (strcase propName))
|
||||||
(setq v nil)
|
(setq v nil)
|
||||||
|
|
||||||
(if (= :vlax-true (vla-get-isdynamicblock blk))
|
(if (= :vlax-true (vla-get-isdynamicblock blk))
|
||||||
(progn
|
(progn
|
||||||
(setq props (vlax-invoke blk 'GetDynamicBlockProperties))
|
(setq props (vlax-invoke blk 'GetDynamicBlockProperties))
|
||||||
@ -64,50 +63,46 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defun parse-ptag1-anchor (ptag / s parts prefix section third kind idx)
|
(defun parse-ptag1-anchor (ptag / s parts prefix section third kind idx)
|
||||||
(setq s (strcase (vl-string-trim " " ptag)))
|
(setq s (strcase (vl-string-trim " " ptag)))
|
||||||
(if (and s (vl-string-search "_" s))
|
(if (and s (vl-string-search "_" s))
|
||||||
(progn
|
(progn
|
||||||
(setq parts (splitUnderscore s))
|
(setq parts (splitUnderscore s))
|
||||||
(if (= (length parts) 3)
|
(if (>= (length parts) 3)
|
||||||
(progn
|
(progn
|
||||||
(setq prefix (nth 0 parts))
|
(setq prefix (nth 0 parts))
|
||||||
(setq section (atoi (nth 1 parts)))
|
(setq section (atoi (nth 1 parts)))
|
||||||
(setq third (nth 2 parts))
|
(setq third (nth 2 parts))
|
||||||
|
(setq kind nil idx 1)
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((or
|
((or (wcmatch third "TPE*") (wcmatch third "PE*") (wcmatch third "LPE*") (wcmatch third "RPE*"))
|
||||||
(wcmatch third "TPE*")
|
(setq kind "TPE")
|
||||||
(wcmatch third "PE*")
|
(setq idx (atoi (substr third 4)))
|
||||||
(wcmatch third "LPE*")
|
|
||||||
(wcmatch third "RPE*")
|
|
||||||
)
|
|
||||||
(setq kind "TPE")
|
|
||||||
(setq idx
|
|
||||||
(cond
|
|
||||||
((wcmatch third "TPE*") (atoi (substr third 4)))
|
|
||||||
((wcmatch third "LPE*") (atoi (substr third 4)))
|
|
||||||
((wcmatch third "RPE*") (atoi (substr third 4)))
|
|
||||||
(T (atoi (substr third 3))) ; PE*
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
((wcmatch third "EPC*") (setq kind "EPC") (setq idx (atoi (substr third 4))))
|
((wcmatch third "EPC*") (setq kind "EPC") (setq idx (atoi (substr third 4))))
|
||||||
|
((wcmatch third "SS*") (setq kind "SS") (setq idx (atoi (substr third 3))))
|
||||||
|
((wcmatch third "S*") (setq kind "BTN") (setq idx (atoi (substr third 2))))
|
||||||
|
((wcmatch third "BCN*")
|
||||||
|
(setq idx (atoi (substr third 4)))
|
||||||
|
(if (and (>= (length parts) 4) (= (nth 3 parts) "H"))
|
||||||
|
(setq kind "HORN")
|
||||||
|
(setq kind "BCN")
|
||||||
|
)
|
||||||
|
)
|
||||||
((wcmatch third "VFD*") (setq kind "VFD") (setq idx (atoi (substr third 4))))
|
((wcmatch third "VFD*") (setq kind "VFD") (setq idx (atoi (substr third 4))))
|
||||||
(t (setq kind nil) (setq idx 0))
|
|
||||||
)
|
)
|
||||||
(if (and kind prefix (> section 0) (> idx 0))
|
|
||||||
|
(if (and kind prefix (> section 0))
|
||||||
(list prefix section kind idx)
|
(list prefix section kind idx)
|
||||||
nil
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
nil
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
nil
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
(defun parse-key (key / parts prefix section)
|
(defun parse-key (key / parts prefix section)
|
||||||
(setq parts (splitUnderscore (strcase key)))
|
(setq parts (splitUnderscore (strcase key)))
|
||||||
(if (= (length parts) 2)
|
(if (= (length parts) 2)
|
||||||
@ -191,11 +186,15 @@
|
|||||||
endRef baseLen epcCandidate epcLen
|
endRef baseLen epcCandidate epcLen
|
||||||
included
|
included
|
||||||
prefixStats maxAny maxGeom
|
prefixStats maxAny maxGeom
|
||||||
hasT hasE hasV isLastAny isLastGeom reason)
|
hasT hasE hasV isLastAny isLastGeom reason btnMap beaconMap hornMap ssMap)
|
||||||
|
|
||||||
(setq tpeMap '())
|
(setq tpeMap '())
|
||||||
(setq epcMap '())
|
(setq epcMap '())
|
||||||
(setq vfdPresence '())
|
(setq vfdPresence '())
|
||||||
|
(setq btnMap '())
|
||||||
|
(setq beaconMap '())
|
||||||
|
(setq hornMap '())
|
||||||
|
(setq ssMap '())
|
||||||
|
|
||||||
(setq ss (ssget "X" '((0 . "INSERT"))))
|
(setq ss (ssget "X" '((0 . "INSERT"))))
|
||||||
(if (not ss)
|
(if (not ss)
|
||||||
@ -208,15 +207,32 @@
|
|||||||
(setq blk (vlax-ename->vla-object ent))
|
(setq blk (vlax-ename->vla-object ent))
|
||||||
(setq effName (strcase (vla-get-EffectiveName blk)))
|
(setq effName (strcase (vla-get-EffectiveName blk)))
|
||||||
|
|
||||||
(if (or (= effName "CLX_TPE") (= effName "CLX_EPC") (= effName "VFD_V2"))
|
(if (or
|
||||||
|
(= effName "CLX_TPE")
|
||||||
|
(= effName "CLX_TPE1")
|
||||||
|
(= effName "CLX_EPC")
|
||||||
|
(= effName "VFD_V2")
|
||||||
|
(= effName "CLX_GS")
|
||||||
|
(= effName "CLX_GS1")
|
||||||
|
(= effName "CLX_LT")
|
||||||
|
(= effName "CLX_LT1")
|
||||||
|
(= effName "AS_LTH")
|
||||||
|
(= effName "CLX_SS_1")
|
||||||
|
)
|
||||||
|
|
||||||
(progn
|
(progn
|
||||||
(setq attList (vlax-invoke blk 'GetAttributes))
|
(setq attList (vlax-invoke blk 'GetAttributes))
|
||||||
(setq ptag (getAttVal attList "P_TAG1"))
|
(setq ptag (getAttVal attList "P_TAG1"))
|
||||||
;; >>> ADDED: TPE-specific dynamic properties (Custom section)
|
(setq tpeRotRaw (getDynPropVal blk "PE ROTATION"))
|
||||||
(setq tpeRotRaw (getDynPropVal blk "PE ROTATION")) ; numeric
|
|
||||||
(setq tpeRot (tpe-rot-deg tpeRotRaw))
|
(setq tpeRot (tpe-rot-deg tpeRotRaw))
|
||||||
|
(if (not (numberp tpeRot)) (setq tpeRot 0.0))
|
||||||
|
|
||||||
(setq tpeDist (getDynPropVal blk "Distance1"))
|
(setq tpeDist (getDynPropVal blk "Distance1"))
|
||||||
|
(if (not (numberp tpeDist)) (setq tpeDist 0.0))
|
||||||
|
|
||||||
(setq blkRot (block-rot-deg blk))
|
(setq blkRot (block-rot-deg blk))
|
||||||
|
(if (not (numberp blkRot)) (setq blkRot 0.0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(setq parsed (parse-ptag1-anchor ptag))
|
(setq parsed (parse-ptag1-anchor ptag))
|
||||||
@ -241,19 +257,76 @@
|
|||||||
(subst (cons key entries) (assoc key tpeMap) tpeMap)
|
(subst (cons key entries) (assoc key tpeMap) tpeMap)
|
||||||
(cons (cons key entries) tpeMap))
|
(cons (cons key entries) tpeMap))
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
;; >>> BUTTONS
|
||||||
|
((= kind "BTN")
|
||||||
|
(setq insPt (vlax-get blk 'InsertionPoint))
|
||||||
|
(setq xy (list (car insPt) (cadr insPt)))
|
||||||
|
(setq entries (cdr (assoc key btnMap)))
|
||||||
|
(if (not entries) (setq entries '()))
|
||||||
|
(setq entries (cons (list idx xy ptag) entries))
|
||||||
|
(setq btnMap
|
||||||
|
(if (assoc key btnMap)
|
||||||
|
(subst (cons key entries) (assoc key btnMap) btnMap)
|
||||||
|
(cons (cons key entries) btnMap))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; >>> BEACONS
|
||||||
|
((= kind "BCN")
|
||||||
|
(setq insPt (vlax-get blk 'InsertionPoint))
|
||||||
|
(setq xy (list (car insPt) (cadr insPt)))
|
||||||
|
(setq entries (cdr (assoc key beaconMap)))
|
||||||
|
(if (not entries) (setq entries '()))
|
||||||
|
(setq entries (cons (list idx xy ptag) entries))
|
||||||
|
(setq beaconMap
|
||||||
|
(if (assoc key beaconMap)
|
||||||
|
(subst (cons key entries) (assoc key beaconMap) beaconMap)
|
||||||
|
(cons (cons key entries) beaconMap))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; >>> HORN BEACONS (AS_LTH)
|
||||||
|
((= kind "HORN")
|
||||||
|
(setq insPt (vlax-get blk 'InsertionPoint))
|
||||||
|
(setq xy (list (car insPt) (cadr insPt)))
|
||||||
|
(setq entries (cdr (assoc key hornMap)))
|
||||||
|
(if (not entries) (setq entries '()))
|
||||||
|
(setq entries (cons (list idx xy ptag) entries))
|
||||||
|
(setq hornMap
|
||||||
|
(if (assoc key hornMap)
|
||||||
|
(subst (cons key entries) (assoc key hornMap) hornMap)
|
||||||
|
(cons (cons key entries) hornMap))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; >>> START/STOP STATIONS
|
||||||
|
((= kind "SS")
|
||||||
|
(setq insPt (vlax-get blk 'InsertionPoint))
|
||||||
|
(setq xy (list (car insPt) (cadr insPt)))
|
||||||
|
(setq entries (cdr (assoc key ssMap)))
|
||||||
|
(if (not entries) (setq entries '()))
|
||||||
|
(setq entries (cons (list idx xy ptag) entries))
|
||||||
|
(setq ssMap
|
||||||
|
(if (assoc key ssMap)
|
||||||
|
(subst (cons key entries) (assoc key ssMap) ssMap)
|
||||||
|
(cons (cons key entries) ssMap))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
((= kind "EPC")
|
((= kind "EPC")
|
||||||
(setq insPt (vlax-get blk 'InsertionPoint))
|
(setq insPt (vlax-get blk 'InsertionPoint))
|
||||||
(setq xy (list (car insPt) (cadr insPt)))
|
(setq xy (list (car insPt) (cadr insPt)))
|
||||||
(setq entries (cdr (assoc key epcMap)))
|
(setq entries (cdr (assoc key epcMap)))
|
||||||
(if (not entries) (setq entries '()))
|
(if (not entries) (setq entries '()))
|
||||||
(setq entries (cons (list idx xy) entries))
|
;; now storing ptag as well
|
||||||
|
(setq entries (cons (list idx xy ptag) entries))
|
||||||
(setq epcMap
|
(setq epcMap
|
||||||
(if (assoc key epcMap)
|
(if (assoc key epcMap)
|
||||||
(subst (cons key entries) (assoc key epcMap) epcMap)
|
(subst (cons key entries) (assoc key epcMap) epcMap)
|
||||||
(cons (cons key entries) epcMap))
|
(cons (cons key entries) epcMap))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
((= kind "VFD")
|
((= kind "VFD")
|
||||||
(if (not (assoc key vfdPresence))
|
(if (not (assoc key vfdPresence))
|
||||||
(setq vfdPresence (cons (cons key T) vfdPresence)))
|
(setq vfdPresence (cons (cons key T) vfdPresence)))
|
||||||
@ -393,7 +466,7 @@
|
|||||||
(setq fh (open outPath "w"))
|
(setq fh (open outPath "w"))
|
||||||
;; >>> ADDED: record_type + TPE columns
|
;; >>> ADDED: record_type + TPE columns
|
||||||
(write-line
|
(write-line
|
||||||
"record_type,conveyor_key,sec,included,reason,has_tpe,has_epc,has_vfd,is_last_any,is_last_geom,start_x,start_y,end_x,end_y,tpe_name,tpe_x,tpe_y,tpe_rotation,tpe_block_rotation,tpe_distance"
|
"record_type,conveyor_key,sec,included,reason,has_tpe,has_epc,has_vfd,is_last_any,is_last_geom,start_x,start_y,end_x,end_y,tpe_name,tpe_x,tpe_y,tpe_rotation,tpe_block_rotation,tpe_distance,dev_name,dev_x,dev_y"
|
||||||
fh)
|
fh)
|
||||||
|
|
||||||
|
|
||||||
@ -561,6 +634,90 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
;; --- START STOP STATIONS ---
|
||||||
|
(foreach kv ssMap
|
||||||
|
(setq key (car kv))
|
||||||
|
(foreach it (cdr kv)
|
||||||
|
(setq xy (nth 1 it))
|
||||||
|
(setq devName (nth 2 it))
|
||||||
|
(write-line
|
||||||
|
(strcat
|
||||||
|
"SS," key ",,,,,,,,,,,,,,,,,,,"
|
||||||
|
devName "," (rtos (car xy) 2 6) "," (rtos (cadr xy) 2 6)
|
||||||
|
)
|
||||||
|
fh
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
;; --- BUTTONS ---
|
||||||
|
(foreach kv btnMap
|
||||||
|
(setq key (car kv))
|
||||||
|
(foreach it (cdr kv)
|
||||||
|
(setq xy (nth 1 it))
|
||||||
|
(setq devName (nth 2 it))
|
||||||
|
(write-line
|
||||||
|
(strcat
|
||||||
|
"S," key ",,,,,,,,,,,,,,,,,,,"
|
||||||
|
devName "," (rtos (car xy) 2 6) "," (rtos (cadr xy) 2 6)
|
||||||
|
)
|
||||||
|
fh
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; --- BEACONS ---
|
||||||
|
(foreach kv beaconMap
|
||||||
|
(setq key (car kv))
|
||||||
|
(foreach it (cdr kv)
|
||||||
|
(setq xy (nth 1 it))
|
||||||
|
(setq devName (nth 2 it))
|
||||||
|
(write-line
|
||||||
|
(strcat
|
||||||
|
"BCN," key ",,,,,,,,,,,,,,,,,,,"
|
||||||
|
devName "," (rtos (car xy) 2 6) "," (rtos (cadr xy) 2 6)
|
||||||
|
)
|
||||||
|
fh
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; --- HORN BEACONS ---
|
||||||
|
(foreach kv hornMap
|
||||||
|
(setq key (car kv))
|
||||||
|
(foreach it (cdr kv)
|
||||||
|
(setq xy (nth 1 it))
|
||||||
|
(setq devName (nth 2 it))
|
||||||
|
(write-line
|
||||||
|
(strcat
|
||||||
|
"BCN," key ",,,,,,,,,,,,,,,,,,,"
|
||||||
|
devName "," (rtos (car xy) 2 6) "," (rtos (cadr xy) 2 6)
|
||||||
|
)
|
||||||
|
fh
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
;; --- EPC DEVICES ---
|
||||||
|
(foreach kv epcMap
|
||||||
|
(setq key (car kv))
|
||||||
|
(foreach it (cdr kv)
|
||||||
|
(setq xy (nth 1 it))
|
||||||
|
(setq devName (nth 2 it))
|
||||||
|
|
||||||
|
(write-line
|
||||||
|
(strcat
|
||||||
|
"EPC," key
|
||||||
|
",,,,,,,,,,,,,,,,,,," ;; up to tpe_distance (19 empty fields)
|
||||||
|
devName ","
|
||||||
|
(rtos (car xy) 2 6) ","
|
||||||
|
(rtos (cadr xy) 2 6)
|
||||||
|
)
|
||||||
|
fh
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
(close fh)
|
(close fh)
|
||||||
(princ (strcat "\nExported conveyors to: " outPath))
|
(princ (strcat "\nExported conveyors to: " outPath))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user