Compare commits
No commits in common. "main" and "lukinio" have entirely different histories.
BIN
AutoCAD/IO/IO.xlsx
Normal file
BIN
AutoCAD/IO/IO.xlsx
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -61,28 +61,13 @@ def family_keys(dev: str):
|
|||||||
seen.add(k); out.append(k)
|
seen.add(k); out.append(k)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def bcn_desc_s_stack(dev: str, all_devices: set) -> str | None:
|
def fallback_desc(dev: str) -> str:
|
||||||
"""Returns IO LINK description for S-prefixed BCNs, or None if not applicable."""
|
|
||||||
import re as _re
|
|
||||||
d = dev.upper()
|
|
||||||
m = _re.match(r"(S\d+)_BCN\d*", d)
|
|
||||||
if not m:
|
|
||||||
return None
|
|
||||||
base = m.group(1)
|
|
||||||
jr_pattern = _re.compile(rf"{_re.escape(base)}_JR\d")
|
|
||||||
has_jr = any(jr_pattern.search(dv) for dv in all_devices)
|
|
||||||
if has_jr:
|
|
||||||
return "IO LINK 3 STACK G/A/B BEACON"
|
|
||||||
return "IO LINK 2 STACK G/B BEACON"
|
|
||||||
|
|
||||||
def fallback_desc(dev: str, all_devices: set | None = None) -> str:
|
|
||||||
import re as _re
|
import re as _re
|
||||||
d = dev.upper()
|
d = dev.upper()
|
||||||
if d == "SPARE": return ""
|
if d == "SPARE": return ""
|
||||||
if "VFD" in d and ("DISC" in d or "DSIC" in d): return "DISCONNECT AUX"
|
if "VFD" in d and ("DISC" in d or "DSIC" in d): return "DISCONNECT AUX"
|
||||||
if _re.search(r"_TPE\d+|^TPE\d+", d): return "TRACKING PHOTOEYE"
|
if _re.search(r"_TPE\d+|^TPE\d+", d): return "TRACKING PHOTOEYE"
|
||||||
if _re.search(r"_JPE\d+|^JPE\d+", d): return "JAM PHOTOEYE"
|
if _re.search(r"_JPE\d+|^JPE\d+", d): return "JAM PHOTOEYE"
|
||||||
if _re.search(r"S\d+_PE\d*|_PE\d+|^PE\d+", d): return "CHUTE DISABLE PHOTOEYE"
|
|
||||||
if _re.search(r"_EPC\d+|^EPC\d+", d): return "E-STOP PULLCORD"
|
if _re.search(r"_EPC\d+|^EPC\d+", d): return "E-STOP PULLCORD"
|
||||||
if "ENSH" in d: return "SHAFT ENCODER"
|
if "ENSH" in d: return "SHAFT ENCODER"
|
||||||
if "ENW" in d: return "WHEEL ENCODER"
|
if "ENW" in d: return "WHEEL ENCODER"
|
||||||
@ -93,9 +78,6 @@ def fallback_desc(dev: str, all_devices: set | None = None) -> str:
|
|||||||
if any(x in d for x in ["_SOL","_SOV","_SV","_SOLV"]): return "SOLENOID VALVE"
|
if any(x in d for x in ["_SOL","_SOV","_SV","_SOLV"]): return "SOLENOID VALVE"
|
||||||
if _re.search(r"_FIOH\d+|^FIOH\d+", d): return "I/O LINK HUB"
|
if _re.search(r"_FIOH\d+|^FIOH\d+", d): return "I/O LINK HUB"
|
||||||
if "BCN" in d:
|
if "BCN" in d:
|
||||||
s_bcn_desc = bcn_desc_s_stack(d, all_devices or set())
|
|
||||||
if s_bcn_desc:
|
|
||||||
return s_bcn_desc
|
|
||||||
if d.endswith("_A"): return "AMBER BEACON LIGHT"
|
if d.endswith("_A"): return "AMBER BEACON LIGHT"
|
||||||
if d.endswith("_R"): return "RED BEACON LIGHT"
|
if d.endswith("_R"): return "RED BEACON LIGHT"
|
||||||
if d.endswith("_G"): return "GREEN BEACON LIGHT"
|
if d.endswith("_G"): return "GREEN BEACON LIGHT"
|
||||||
@ -115,13 +97,13 @@ def fallback_desc(dev: str, all_devices: set | None = None) -> str:
|
|||||||
if d.startswith("PDP") and "_PWM" in d: return "PHASE MONITOR"
|
if d.startswith("PDP") and "_PWM" in d: return "PHASE MONITOR"
|
||||||
return "DEVICE"
|
return "DEVICE"
|
||||||
|
|
||||||
def desc_for(dev: str, canon: dict, all_devices: set | None = None) -> str:
|
def desc_for(dev: str, canon: dict) -> str:
|
||||||
s = str(dev).strip().upper()
|
s = str(dev).strip().upper()
|
||||||
if not s: return ""
|
if not s: return ""
|
||||||
if s in canon: return canon[s]
|
if s in canon: return canon[s]
|
||||||
for k in family_keys(s):
|
for k in family_keys(s):
|
||||||
if k in canon: return canon[k]
|
if k in canon: return canon[k]
|
||||||
return fallback_desc(s, all_devices)
|
return fallback_desc(s)
|
||||||
|
|
||||||
def choose_order(controller_name: str, available_columns):
|
def choose_order(controller_name: str, available_columns):
|
||||||
s = str(controller_name).upper()
|
s = str(controller_name).upper()
|
||||||
@ -163,17 +145,6 @@ def main():
|
|||||||
|
|
||||||
canon_map = load_canon([Path(p) for p in args.canon])
|
canon_map = load_canon([Path(p) for p in args.canon])
|
||||||
|
|
||||||
all_devices = set()
|
|
||||||
for _, r in df.iterrows():
|
|
||||||
ctrl = str(r.get("P_TAG1", "")).strip()
|
|
||||||
if not ctrl:
|
|
||||||
continue
|
|
||||||
order = choose_order(ctrl, sig_cols_available)
|
|
||||||
for sig in order:
|
|
||||||
val = r.get(sig)
|
|
||||||
if pd.notna(val) and str(val).strip():
|
|
||||||
all_devices.add(str(val).strip().upper())
|
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
for _, r in df.iterrows():
|
for _, r in df.iterrows():
|
||||||
ctrl = str(r.get("P_TAG1","")).strip()
|
ctrl = str(r.get("P_TAG1","")).strip()
|
||||||
@ -186,7 +157,7 @@ def main():
|
|||||||
if dev == "":
|
if dev == "":
|
||||||
dev = "SPARE"
|
dev = "SPARE"
|
||||||
addr = f"{ctrl}_{sig}"
|
addr = f"{ctrl}_{sig}"
|
||||||
desc = "" if dev.upper()=="SPARE" else desc_for(dev, canon_map, all_devices)
|
desc = "" if dev.upper()=="SPARE" else desc_for(dev, canon_map)
|
||||||
dU = dev.upper()
|
dU = dev.upper()
|
||||||
if re.search(r'_ESTOP1$', dU): desc = "ESTOP OK"
|
if re.search(r'_ESTOP1$', dU): desc = "ESTOP OK"
|
||||||
elif re.search(r'_SS\d+_SPB_LT$', dU): desc = "SS STATION START PUSHBUTTON LIGHT"
|
elif re.search(r'_SS\d+_SPB_LT$', dU): desc = "SS STATION START PUSHBUTTON LIGHT"
|
||||||
@ -198,7 +169,6 @@ def main():
|
|||||||
elif re.search(r'_JR\d+_PB$', dU): desc = "JAM RESET PUSHBUTTON"
|
elif re.search(r'_JR\d+_PB$', dU): desc = "JAM RESET PUSHBUTTON"
|
||||||
elif re.search(r'_EN\d*_PB_LT$', dU): desc = "ENABLE PUSHBUTTON LIGHT"
|
elif re.search(r'_EN\d*_PB_LT$', dU): desc = "ENABLE PUSHBUTTON LIGHT"
|
||||||
elif re.search(r'_EN\d*_PB$', dU): desc = "ENABLE PUSHBUTTON"
|
elif re.search(r'_EN\d*_PB$', dU): desc = "ENABLE PUSHBUTTON"
|
||||||
elif re.search(r'_PR\d*_PB$', dU): desc = "PACKAGE RELEASE PUSHBUTTON"
|
|
||||||
rows.append({
|
rows.append({
|
||||||
"Controller name": ctrl,
|
"Controller name": ctrl,
|
||||||
"Signal type": sig,
|
"Signal type": sig,
|
||||||
|
|||||||
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM01-IO.bak
Normal file
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM01-IO.bak
Normal file
Binary file not shown.
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM01-IO.dwg
Normal file
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM01-IO.dwg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM14-Loop.bak
Normal file
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM14-Loop.bak
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM15-IO.dwg
Normal file
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM15-IO.dwg
Normal file
Binary file not shown.
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM15-Loop.bak
Normal file
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM15-Loop.bak
Normal file
Binary file not shown.
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM15-Loop.dwg
Normal file
BIN
AutoCAD/MCM_Installer_drawing/2433-AMZ-CDW5-MCM15-Loop.dwg
Normal file
Binary file not shown.
BIN
AutoCAD/MCM_Installer_drawing/2503_AMZ-BNA8-MCM02-600 1.bak
Normal file
BIN
AutoCAD/MCM_Installer_drawing/2503_AMZ-BNA8-MCM02-600 1.bak
Normal file
Binary file not shown.
@ -202,7 +202,7 @@
|
|||||||
(append result (list line))
|
(append result (list line))
|
||||||
)
|
)
|
||||||
|
|
||||||
(defun getDPMDataFromCSV ( / file filename line headers row dpm ip name deviceIP port partNumber dpmList deviceGroups currentGroup zoneRaw zoneNumber zoneTag)
|
(defun getDPMDataFromCSV ( / file filename line headers row dpm ip name deviceIP port partNumber dpmList deviceGroups currentGroup zoneRaw zoneNumber)
|
||||||
(setq filename (getfiled "Select CSV File" (strcat (getenv "USERPROFILE") "\\Desktop\\") "csv" 0))
|
(setq filename (getfiled "Select CSV File" (strcat (getenv "USERPROFILE") "\\Desktop\\") "csv" 0))
|
||||||
(if (not filename)
|
(if (not filename)
|
||||||
(progn (princ "\nNo file selected.") (exit))
|
(progn (princ "\nNo file selected.") (exit))
|
||||||
@ -220,7 +220,6 @@
|
|||||||
(setq deviceGroups '())
|
(setq deviceGroups '())
|
||||||
(setq currentGroup '())
|
(setq currentGroup '())
|
||||||
(setq zoneNumber "")
|
(setq zoneNumber "")
|
||||||
(setq zoneTag "")
|
|
||||||
|
|
||||||
(while (setq line (read-line file))
|
(while (setq line (read-line file))
|
||||||
(setq row (parseCSVLine line))
|
(setq row (parseCSVLine line))
|
||||||
@ -235,10 +234,9 @@
|
|||||||
(setq port (nth 8 row))
|
(setq port (nth 8 row))
|
||||||
(setq zoneRaw (nth 9 row))
|
(setq zoneRaw (nth 9 row))
|
||||||
|
|
||||||
;; Preserve full zone tag (e.g., "MCM03") for notes, and also extract zone number digits (e.g., "03")
|
;; Extract zone number - preserve it as-is with leading zeros
|
||||||
(if (and zoneRaw (/= zoneRaw ""))
|
(if (and zoneRaw (/= zoneRaw ""))
|
||||||
(progn
|
(progn
|
||||||
(setq zoneTag (str-trim zoneRaw))
|
|
||||||
;; Extract only digits from zone string (e.g., "MCM01" -> "01")
|
;; Extract only digits from zone string (e.g., "MCM01" -> "01")
|
||||||
(setq zoneNumber
|
(setq zoneNumber
|
||||||
(str-trim
|
(str-trim
|
||||||
@ -275,8 +273,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
(if (not (assoc dpm dpmList))
|
(if (not (assoc dpm dpmList))
|
||||||
;; Store: (DPM -> (ip zoneNumber zoneTag))
|
(setq dpmList (append dpmList (list (cons dpm (list ip zoneNumber)))))
|
||||||
(setq dpmList (append dpmList (list (cons dpm (list ip zoneNumber zoneTag)))))
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -328,127 +325,7 @@
|
|||||||
(list dpmList deviceGroups)
|
(list dpmList deviceGroups)
|
||||||
)
|
)
|
||||||
|
|
||||||
(defun createEthernetCableScheduleTable (originX originY dpmName deviceGroup / doc ms insPt tbl rowHeight colWidths idx devicePair toName fromName cblTag rowIdx colIdx)
|
(defun c:init-diagrams ( / blockName count offsetX i x y basePt targetPt lastEnt dpmPair dpmName dpmIP deviceGroup dpmUpsPt dpmUpsObj tag ent vlaObj zoneName zoneNumber dpmData)
|
||||||
;; Creates a 3-column x 26-row table:
|
|
||||||
;; Row 1 (merged): "<DPM_NAME> ETHERNET CABLE SCHEDULE"
|
|
||||||
;; Row 2: headers - "CABLE TAG", "CABLE LABEL TO", "CABLE LABEL FROM"
|
|
||||||
;; Rows 3..26 (24 data rows):
|
|
||||||
;; Col A: CBL01..CBL24
|
|
||||||
;; Col B: device NAMEs from CSV (in order)
|
|
||||||
;; Col C: <DPM_NAME>-ETHCBL P5 to P28
|
|
||||||
|
|
||||||
;; Calculate row height from total table height (12.5450) / 26 rows
|
|
||||||
(setq rowHeight (/ 12.5450 26.0))
|
|
||||||
|
|
||||||
;; Insertion point shifts with layout X offset
|
|
||||||
(setq insPt (vlax-3d-point (list (+ originX 31.1911) (+ originY 12.9267) 0.0)))
|
|
||||||
|
|
||||||
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
|
|
||||||
(setq ms (vla-get-ModelSpace doc))
|
|
||||||
|
|
||||||
;; Create table: 26 rows, 3 columns
|
|
||||||
;; vla-AddTable params: space, insertionPoint, numRows, numCols, rowHeight, colWidth
|
|
||||||
(setq tbl (vla-AddTable ms insPt 26 3 rowHeight 3.9867))
|
|
||||||
|
|
||||||
;; Set layer
|
|
||||||
(vla-put-Layer tbl "0")
|
|
||||||
|
|
||||||
;; Try to set table style to "AS"
|
|
||||||
(vl-catch-all-apply 'vla-put-StyleName (list tbl "AS"))
|
|
||||||
|
|
||||||
;; Set column widths to achieve total width of 11.9601
|
|
||||||
;; Column A (CABLE TAG): ~2.0
|
|
||||||
;; Columns B & C: ~4.98 each
|
|
||||||
(vl-catch-all-apply 'vla-SetColumnWidth (list tbl 0 2.0))
|
|
||||||
(vl-catch-all-apply 'vla-SetColumnWidth (list tbl 1 4.98005))
|
|
||||||
(vl-catch-all-apply 'vla-SetColumnWidth (list tbl 2 4.98005))
|
|
||||||
|
|
||||||
;; Set text height, alignment, text style, and margins for all cells
|
|
||||||
;; acMiddleCenter = 5
|
|
||||||
(setq rowIdx 0)
|
|
||||||
(while (< rowIdx 26)
|
|
||||||
(setq colIdx 0)
|
|
||||||
(while (< colIdx 3)
|
|
||||||
(vl-catch-all-apply 'vla-SetTextHeight (list tbl rowIdx colIdx 0.1805))
|
|
||||||
(vl-catch-all-apply 'vla-SetCellAlignment (list tbl rowIdx colIdx 5))
|
|
||||||
(vl-catch-all-apply 'vla-SetTextStyle (list tbl rowIdx colIdx "WD"))
|
|
||||||
(setq colIdx (1+ colIdx))
|
|
||||||
)
|
|
||||||
(setq rowIdx (1+ rowIdx))
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Set cell margins: horizontal and vertical = 0.1083
|
|
||||||
;; acTableCellMarginHorzSpacing = 1, acTableCellMarginVertSpacing = 2
|
|
||||||
(vl-catch-all-apply 'vla-SetMargin (list tbl 1 0.1083)) ;; horizontal
|
|
||||||
(vl-catch-all-apply 'vla-SetMargin (list tbl 2 0.1083)) ;; vertical
|
|
||||||
|
|
||||||
;; Row 1: Merge all columns and set title
|
|
||||||
(vl-catch-all-apply 'vla-MergeCells (list tbl 0 0 0 2))
|
|
||||||
(vla-SetText tbl 0 0 (strcat dpmName " ETHERNET CABLE SCHEDULE"))
|
|
||||||
|
|
||||||
;; Row 2: Headers
|
|
||||||
(vla-SetText tbl 1 0 "CABLE TAG")
|
|
||||||
(vla-SetText tbl 1 1 "CABLE LABEL TO")
|
|
||||||
(vla-SetText tbl 1 2 "CABLE LABEL FROM")
|
|
||||||
|
|
||||||
;; Rows 3..26 (indices 2..25): Data rows
|
|
||||||
(setq idx 0)
|
|
||||||
(while (< idx 24)
|
|
||||||
;; Column A: CBL01 to CBL24
|
|
||||||
(setq cblTag (strcat "CBL" (if (< (1+ idx) 10) "0" "") (itoa (1+ idx))))
|
|
||||||
|
|
||||||
;; Column B: Device name from CSV
|
|
||||||
(setq devicePair (nth idx deviceGroup))
|
|
||||||
(setq toName (if devicePair (cdr (assoc "NAME" devicePair)) "SPARE"))
|
|
||||||
|
|
||||||
;; Column C: <DPM_NAME>-ETHCBL P5 to P28
|
|
||||||
(setq fromName (strcat dpmName "-ETHCBL P" (itoa (+ 5 idx))))
|
|
||||||
|
|
||||||
(vla-SetText tbl (+ 2 idx) 0 cblTag)
|
|
||||||
(vla-SetText tbl (+ 2 idx) 1 toName)
|
|
||||||
(vla-SetText tbl (+ 2 idx) 2 fromName)
|
|
||||||
|
|
||||||
(setq idx (1+ idx))
|
|
||||||
)
|
|
||||||
tbl
|
|
||||||
)
|
|
||||||
|
|
||||||
(defun insertDLRNoteMText (originX originY zoneTag / bs notePt noteText)
|
|
||||||
;; Creates the note:
|
|
||||||
;; SEE DRAWING 2433-AMZ-CDW5-<ZONE>-701 FOR
|
|
||||||
;; DLR NETWORK LOOP
|
|
||||||
(setq bs (chr 92)) ;; backslash for MText formatting codes
|
|
||||||
(setq notePt (list (+ originX 5.5183) (+ originY 10.0751) 0.0))
|
|
||||||
(setq noteText
|
|
||||||
(strcat
|
|
||||||
bs "pxqr;"
|
|
||||||
"SEE DRAWING 2433-AMZ-CDW5-"
|
|
||||||
zoneTag
|
|
||||||
"-701 FOR"
|
|
||||||
bs "P"
|
|
||||||
"DLR NETWORK LOOP"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(entmakex
|
|
||||||
(list
|
|
||||||
(cons 0 "MTEXT")
|
|
||||||
(cons 100 "AcDbEntity")
|
|
||||||
(cons 8 "0")
|
|
||||||
(cons 100 "AcDbMText")
|
|
||||||
(cons 10 notePt)
|
|
||||||
(cons 40 0.2) ;; text height
|
|
||||||
(cons 7 "WD") ;; text style
|
|
||||||
(cons 71 1) ;; attachment point: top left
|
|
||||||
(cons 41 8.2690) ;; defined width
|
|
||||||
(cons 44 1.0) ;; line spacing factor
|
|
||||||
(cons 73 1) ;; line spacing style: at least
|
|
||||||
(cons 50 0.0) ;; rotation
|
|
||||||
(cons 1 noteText) ;; contents
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(defun c:init-diagrams ( / blockName count offsetX i x y basePt targetPt lastEnt dpmPair dpmName dpmIP deviceGroup dpmUpsPt dpmUpsObj tag ent vlaObj zoneName zoneNumber zoneTag dpmData)
|
|
||||||
(clearDrawing)
|
(clearDrawing)
|
||||||
(setq blockName "layout")
|
(setq blockName "layout")
|
||||||
(setq csvData (getDPMDataFromCSV))
|
(setq csvData (getDPMDataFromCSV))
|
||||||
@ -458,12 +335,12 @@
|
|||||||
|
|
||||||
(if (and blockName (> count 0))
|
(if (and blockName (> count 0))
|
||||||
(progn
|
(progn
|
||||||
;; Distance between consecutive layout Base Points (inches)
|
(setq offsetX 43.5)
|
||||||
(setq offsetX 48.5)
|
|
||||||
(setq i 0)
|
(setq i 0)
|
||||||
(while (< i count)
|
(while (< i count)
|
||||||
(setq x (* i offsetX))
|
(setq x (* i offsetX))
|
||||||
(setq y 0)
|
(setq y 0)
|
||||||
|
(setq basePt '(0 0 0))
|
||||||
(setq targetPt (list x y 0))
|
(setq targetPt (list x y 0))
|
||||||
|
|
||||||
;; Get DPM data and zone number
|
;; Get DPM data and zone number
|
||||||
@ -472,24 +349,22 @@
|
|||||||
(setq dpmData (cdr dpmPair))
|
(setq dpmData (cdr dpmPair))
|
||||||
(setq dpmIP (car dpmData))
|
(setq dpmIP (car dpmData))
|
||||||
(setq zoneNumber (cadr dpmData))
|
(setq zoneNumber (cadr dpmData))
|
||||||
(setq zoneTag (caddr dpmData))
|
|
||||||
(setq deviceGroup (nth i deviceGroups))
|
(setq deviceGroup (nth i deviceGroups))
|
||||||
|
|
||||||
;; Insert layout
|
;; Insert layout
|
||||||
;; Insert directly at targetPt so the block's Base Point is at the desired XYZ
|
(command "_.-INSERT" blockName basePt 1 1 0)
|
||||||
(command "_.-INSERT" blockName targetPt 1 1 0)
|
|
||||||
(setq lastEnt (entlast))
|
(setq lastEnt (entlast))
|
||||||
(if lastEnt
|
(if lastEnt
|
||||||
(progn
|
(progn
|
||||||
|
(vla-move
|
||||||
|
(vlax-ename->vla-object lastEnt)
|
||||||
|
(vlax-3d-point basePt)
|
||||||
|
(vlax-3d-point targetPt)
|
||||||
|
)
|
||||||
(setLayoutWireNumbers lastEnt zoneNumber i)
|
(setLayoutWireNumbers lastEnt zoneNumber i)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Insert DLR network loop note (one per layout), offset matches screenshot and shifts with layout
|
|
||||||
(if (and zoneTag (/= zoneTag ""))
|
|
||||||
(insertDLRNoteMText x y zoneTag)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Insert DPM-UPS
|
;; Insert DPM-UPS
|
||||||
(setq dpmUpsPt (list (+ x 16.1) (+ y 2.1173) 0))
|
(setq dpmUpsPt (list (+ x 16.1) (+ y 2.1173) 0))
|
||||||
(command "_.-INSERT" "DPM-UPS" dpmUpsPt 1 1 0)
|
(command "_.-INSERT" "DPM-UPS" dpmUpsPt 1 1 0)
|
||||||
@ -508,11 +383,6 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Insert Ethernet Cable Schedule table (one per DPM/layout)
|
|
||||||
(if (and dpmName (/= dpmName "") deviceGroup)
|
|
||||||
(createEthernetCableScheduleTable x y dpmName deviceGroup)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Insert ZONE_32H
|
;; Insert ZONE_32H
|
||||||
(setq desiredX (+ x 0.7658))
|
(setq desiredX (+ x 0.7658))
|
||||||
(setq desiredY (+ y 25.6873))
|
(setq desiredY (+ y 25.6873))
|
||||||
@ -541,5 +411,4 @@
|
|||||||
(princ "\nInvalid input.")
|
(princ "\nInvalid input.")
|
||||||
)
|
)
|
||||||
(princ)
|
(princ)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
@ -327,22 +327,6 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
;; --- FIOM/FIOH right-side X normalization ---
|
|
||||||
;; For FIOM/FIOH: DESCA10..16 (and any paired/single cases) should share the same X as DESCA09.
|
|
||||||
(if (and (>= tagNum mirrorThreshold) ; right side for FIOM/FIOH
|
|
||||||
(or (= blkName "PLCIO_ARMORBLOCK_FIOM") (= blkName "PLCIO_ARMORBLOCK_FIOH")))
|
|
||||||
(progn
|
|
||||||
(setq refAtt (getAttObj attList "DESCA09"))
|
|
||||||
(if refAtt
|
|
||||||
(progn
|
|
||||||
(setq refPt (vlax-get refAtt 'InsertionPoint))
|
|
||||||
(setq dx (- (car refPt) (car pt1)))
|
|
||||||
(setq newPt1Adjusted (list (+ (car newPt1Adjusted) dx) (cadr newPt1Adjusted) (caddr newPt1Adjusted)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; === Check patterns: single cable or splitter? ===
|
;; === Check patterns: single cable or splitter? ===
|
||||||
(if (and val1 val2
|
(if (and val1 val2
|
||||||
(or (and (vl-string-search "SEL" val1) (vl-string-search "SEL" val2))
|
(or (and (vl-string-search "SEL" val1) (vl-string-search "SEL" val2))
|
||||||
@ -392,15 +376,6 @@
|
|||||||
)
|
)
|
||||||
(setBlockAttr newBlock1 "TAG1" taga1)
|
(setBlockAttr newBlock1 "TAG1" taga1)
|
||||||
(setCableDesc2 newBlock1 val1)
|
(setCableDesc2 newBlock1 val1)
|
||||||
;; Mirror cordset on right side
|
|
||||||
(if (>= tagNum mirrorThreshold)
|
|
||||||
(progn
|
|
||||||
(setq mPt (vlax-get newBlock1 'InsertionPoint))
|
|
||||||
(command "_MIRROR" (vlax-vla-object->ename newBlock1) "" mPt (list (car mPt) (+ (cadr mPt) 0.1) (caddr mPt)) "N")
|
|
||||||
(entdel (vlax-vla-object->ename newBlock1))
|
|
||||||
(setq newBlock1 (vlax-ename->vla-object (entlast)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
(progn
|
(progn
|
||||||
;; === SPLITTER: two cables + splitter ===
|
;; === SPLITTER: two cables + splitter ===
|
||||||
@ -421,21 +396,6 @@
|
|||||||
(setBlockAttr newBlock2 "TAG1" taga2)
|
(setBlockAttr newBlock2 "TAG1" taga2)
|
||||||
(setCableDesc2 newBlock2 val2)
|
(setCableDesc2 newBlock2 val2)
|
||||||
|
|
||||||
;; Mirror both cordsets on right side
|
|
||||||
(if (>= tagNum mirrorThreshold)
|
|
||||||
(progn
|
|
||||||
(setq mPt1 (vlax-get newBlock1 'InsertionPoint))
|
|
||||||
(command "_MIRROR" (vlax-vla-object->ename newBlock1) "" mPt1 (list (car mPt1) (+ (cadr mPt1) 0.1) (caddr mPt1)) "N")
|
|
||||||
(entdel (vlax-vla-object->ename newBlock1))
|
|
||||||
(setq newBlock1 (vlax-ename->vla-object (entlast)))
|
|
||||||
|
|
||||||
(setq mPt2 (vlax-get newBlock2 'InsertionPoint))
|
|
||||||
(command "_MIRROR" (vlax-vla-object->ename newBlock2) "" mPt2 (list (car mPt2) (+ (cadr mPt2) 0.1) (caddr mPt2)) "N")
|
|
||||||
(entdel (vlax-vla-object->ename newBlock2))
|
|
||||||
(setq newBlock2 (vlax-ename->vla-object (entlast)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; 3) Splitter between them
|
;; 3) Splitter between them
|
||||||
(setq x3 (+ (car newPt1Adjusted) (if (< tagNum mirrorThreshold) 1.25 -1.25)))
|
(setq x3 (+ (car newPt1Adjusted) (if (< tagNum mirrorThreshold) 1.25 -1.25)))
|
||||||
(setq y3 (/ (+ (cadr newPt1Adjusted) y2) 2.0))
|
(setq y3 (/ (+ (cadr newPt1Adjusted) y2) 2.0))
|
||||||
@ -458,15 +418,15 @@
|
|||||||
(setq moveX -0.5) ; left shift
|
(setq moveX -0.5) ; left shift
|
||||||
(setq moveY 0.5) ; upward shift
|
(setq moveY 0.5) ; upward shift
|
||||||
|
|
||||||
;; Use actual insertion points (robust after mirroring)
|
(vla-move newBlock1 (vlax-3d-point newPt1Adjusted)
|
||||||
(setq basePt1 (vlax-get newBlock1 'InsertionPoint))
|
(vlax-3d-point (+ (car newPt1Adjusted) moveX)
|
||||||
(setq targetPt1 (list (+ (car basePt1) moveX) (+ (cadr basePt1) moveY) (caddr basePt1)))
|
(+ (cadr newPt1Adjusted) moveY)
|
||||||
(vla-move newBlock1 (vlax-3d-point basePt1) (vlax-3d-point targetPt1))
|
(caddr newPt1Adjusted)))
|
||||||
|
|
||||||
(setq basePt2 (vlax-get newBlock2 'InsertionPoint))
|
(vla-move newBlock2 (vlax-3d-point newPt2)
|
||||||
;; keep the original "down 0.1" behavior for the 2nd cordset
|
(vlax-3d-point (+ (car newPt2) moveX)
|
||||||
(setq targetPt2 (list (+ (car basePt2) moveX) (+ (cadr basePt2) -0.1) (caddr basePt2)))
|
(- (cadr newPt2) 0.1)
|
||||||
(vla-move newBlock2 (vlax-3d-point basePt2) (vlax-3d-point targetPt2))
|
(caddr newPt2)))
|
||||||
|
|
||||||
;; Ensure splitterEnt exists for both sides
|
;; Ensure splitterEnt exists for both sides
|
||||||
(if (not splitterEnt)
|
(if (not splitterEnt)
|
||||||
@ -475,11 +435,11 @@
|
|||||||
|
|
||||||
;; Move splitter
|
;; Move splitter
|
||||||
(if splitterEnt
|
(if splitterEnt
|
||||||
(progn
|
(vla-move splitterEnt
|
||||||
(setq basePt3 (vlax-get splitterEnt 'InsertionPoint))
|
(vlax-3d-point newPt3)
|
||||||
(setq targetPt3 (list (+ (car basePt3) moveX) (+ (cadr basePt3) moveY -0.3) (caddr basePt3)))
|
(vlax-3d-point (+ (car newPt3) moveX)
|
||||||
(vla-move splitterEnt (vlax-3d-point basePt3) (vlax-3d-point targetPt3))
|
(+ (- (cadr newPt3) 0.3) moveY)
|
||||||
)
|
(caddr newPt3)))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -507,22 +467,6 @@
|
|||||||
(and (vl-string-search "PDP" val1) (vl-string-search "_CB" val1)
|
(and (vl-string-search "PDP" val1) (vl-string-search "_CB" val1)
|
||||||
(vl-string-search "PDP" val2) (vl-string-search "_CB" val2))))
|
(vl-string-search "PDP" val2) (vl-string-search "_CB" val2))))
|
||||||
(progn
|
(progn
|
||||||
;; VFD left-side special case:
|
|
||||||
;; When DESCA05/DESCA06 share a single cable, align its X to DESCA01's cable X.
|
|
||||||
(if (and (= blkName "PLCIO_ARMORPOWERFLEX")
|
|
||||||
(< tagNum mirrorThreshold)
|
|
||||||
(or (= tagNum 5) (= tagNum 6)))
|
|
||||||
(progn
|
|
||||||
(setq refAtt (getAttObj attList "DESCA01"))
|
|
||||||
(if refAtt
|
|
||||||
(progn
|
|
||||||
(setq refPt (vlax-get refAtt 'InsertionPoint))
|
|
||||||
(setq dx (- (car refPt) (car pt1)))
|
|
||||||
(setq newPt1 (list (+ (car newPt1) dx) (cadr newPt1) (caddr newPt1)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
;; Insert single straight block
|
;; Insert single straight block
|
||||||
(command "_-INSERT" "HC01_CORDSET_STR-STR_STRAIGHT" newPt1 1 1 0)
|
(command "_-INSERT" "HC01_CORDSET_STR-STR_STRAIGHT" newPt1 1 1 0)
|
||||||
(setq newBlock (vlax-ename->vla-object (entlast)))
|
(setq newBlock (vlax-ename->vla-object (entlast)))
|
||||||
@ -575,30 +519,12 @@
|
|||||||
(setBlockAttr newBlock2 "TAG1" taga2)
|
(setBlockAttr newBlock2 "TAG1" taga2)
|
||||||
(setCableDesc2 newBlock2 val2)
|
(setCableDesc2 newBlock2 val2)
|
||||||
|
|
||||||
;; Mirror both cordsets on right side
|
|
||||||
(if (>= tagNum mirrorThreshold)
|
|
||||||
(progn
|
|
||||||
(setq mPt1 (vlax-get newBlock1 'InsertionPoint))
|
|
||||||
(command "_MIRROR" (vlax-vla-object->ename newBlock1) "" mPt1 (list (car mPt1) (+ (cadr mPt1) 0.1) (caddr mPt1)) "N")
|
|
||||||
(entdel (vlax-vla-object->ename newBlock1))
|
|
||||||
(setq newBlock1 (vlax-ename->vla-object (entlast)))
|
|
||||||
|
|
||||||
(setq mPt2 (vlax-get newBlock2 'InsertionPoint))
|
|
||||||
(command "_MIRROR" (vlax-vla-object->ename newBlock2) "" mPt2 (list (car mPt2) (+ (cadr mPt2) 0.1) (caddr mPt2)) "N")
|
|
||||||
(entdel (vlax-vla-object->ename newBlock2))
|
|
||||||
(setq newBlock2 (vlax-ename->vla-object (entlast)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(setq x3 (+ x1 (if (< tagNum mirrorThreshold) 1.25 -1.25)))
|
(setq x3 (+ x1 (if (< tagNum mirrorThreshold) 1.25 -1.25)))
|
||||||
(setq y3 (/ (+ y1 y2) 2.0))
|
(setq y3 (/ (+ y1 y2) 2.0))
|
||||||
(setq newPt3 (list x3 y3 0.0))
|
(setq newPt3 (list x3 y3 0.0))
|
||||||
|
|
||||||
(if (< tagNum mirrorThreshold)
|
(if (< tagNum mirrorThreshold)
|
||||||
(progn
|
(command "_-INSERT" "HC01_SPLITTER" newPt3 1 1 0)
|
||||||
(command "_-INSERT" "HC01_SPLITTER" newPt3 1 1 0)
|
|
||||||
(setq splitterEnt (vlax-ename->vla-object (entlast)))
|
|
||||||
)
|
|
||||||
(progn
|
(progn
|
||||||
(command "_-INSERT" "HC01_SPLITTER(RIGHT)" newPt3 1 1 0)
|
(command "_-INSERT" "HC01_SPLITTER(RIGHT)" newPt3 1 1 0)
|
||||||
(setq splitterEnt (vlax-ename->vla-object (entlast)))
|
(setq splitterEnt (vlax-ename->vla-object (entlast)))
|
||||||
@ -611,21 +537,17 @@
|
|||||||
(if (= blkName "PLCIO_ARMORPOWERFLEX")
|
(if (= blkName "PLCIO_ARMORPOWERFLEX")
|
||||||
(progn
|
(progn
|
||||||
(setq shiftY -0.5) ; same vertical shift as single cables
|
(setq shiftY -0.5) ; same vertical shift as single cables
|
||||||
;; VFD splitter-group sits slightly low; nudge the whole group up
|
|
||||||
(setq vfdGroupExtraY 0.3)
|
|
||||||
|
|
||||||
(setq basePt1 (vlax-get newBlock1 'InsertionPoint))
|
(setq basePt1 (vlax-get newBlock1 'InsertionPoint))
|
||||||
(setq basePt2 (vlax-get newBlock2 'InsertionPoint))
|
(setq basePt2 (vlax-get newBlock2 'InsertionPoint))
|
||||||
(setq basePt3 (if splitterEnt (vlax-get splitterEnt 'InsertionPoint) nil))
|
(setq basePt3 (vlax-get (vlax-ename->vla-object (entlast)) 'InsertionPoint))
|
||||||
|
|
||||||
(vla-move newBlock1 (vlax-3d-point basePt1)
|
(vla-move newBlock1 (vlax-3d-point basePt1)
|
||||||
(vlax-3d-point (car basePt1) (+ (cadr basePt1) shiftY vfdGroupExtraY) (caddr basePt1)))
|
(vlax-3d-point (car basePt1) (+ (cadr basePt1) shiftY) (caddr basePt1)))
|
||||||
(vla-move newBlock2 (vlax-3d-point basePt2)
|
(vla-move newBlock2 (vlax-3d-point basePt2)
|
||||||
(vlax-3d-point (car basePt2) (+ (cadr basePt2) shiftY vfdGroupExtraY) (caddr basePt2)))
|
(vlax-3d-point (car basePt2) (+ (cadr basePt2) shiftY) (caddr basePt2)))
|
||||||
(if (and splitterEnt basePt3)
|
(vla-move (vlax-ename->vla-object (entlast)) (vlax-3d-point basePt3)
|
||||||
(vla-move splitterEnt (vlax-3d-point basePt3)
|
(vlax-3d-point (car basePt3) (+ (cadr basePt3) shiftY) (caddr basePt3)))
|
||||||
(vlax-3d-point (car basePt3) (+ (cadr basePt3) shiftY vfdGroupExtraY) (caddr basePt3)))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -676,23 +598,7 @@
|
|||||||
|
|
||||||
;; For PLCIO_ARMORPOWERFLEX, special DESCA11 block placement
|
;; For PLCIO_ARMORPOWERFLEX, special DESCA11 block placement
|
||||||
(if (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagNum 11))
|
(if (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagNum 11))
|
||||||
;; Keep Y tweak, but align X with other right-side VFD cables
|
(setq insPt (list (+ x 2.0) (+ y 0.5) 0.0))
|
||||||
(setq insPt (list (+ x xAdjust) (+ y 0.5) 0.0))
|
|
||||||
)
|
|
||||||
|
|
||||||
;; FIOM/FIOH right-side X normalization: align all DESCA10..16 to DESCA09
|
|
||||||
(if (and (>= tagNum mirrorThreshold)
|
|
||||||
(or (= blkName "PLCIO_ARMORBLOCK_FIOM") (= blkName "PLCIO_ARMORBLOCK_FIOH")))
|
|
||||||
(progn
|
|
||||||
(setq refAtt (getAttObj attList "DESCA09"))
|
|
||||||
(if refAtt
|
|
||||||
(progn
|
|
||||||
(setq refPt (vlax-get refAtt 'InsertionPoint))
|
|
||||||
(setq dx (- (car refPt) (car pt)))
|
|
||||||
(setq insPt (list (+ (car insPt) dx) (cadr insPt) (caddr insPt)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Insert cable block
|
;; Insert cable block
|
||||||
@ -718,8 +624,9 @@
|
|||||||
(setBlockAttr newBlock "TAG1" taga)
|
(setBlockAttr newBlock "TAG1" taga)
|
||||||
(setCableDesc2 newBlock val1)
|
(setCableDesc2 newBlock val1)
|
||||||
|
|
||||||
; Mirror blocks on right side
|
; Mirror blocks for DESCA07 and above except special single DESCA11
|
||||||
(if (>= tagnum mirrorThreshold)
|
(if (and (>= tagnum mirrorThreshold)
|
||||||
|
(not (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagnum 11))))
|
||||||
(progn
|
(progn
|
||||||
(command "_MIRROR" newEnt "" insPt (list (car insPt) (+ (cadr insPt) 0.1)) "N")
|
(command "_MIRROR" newEnt "" insPt (list (car insPt) (+ (cadr insPt) 0.1)) "N")
|
||||||
(entdel newEnt)
|
(entdel newEnt)
|
||||||
@ -801,23 +708,7 @@
|
|||||||
|
|
||||||
;; For PLCIO_ARMORPOWERFLEX, special DESCA11 block placement
|
;; For PLCIO_ARMORPOWERFLEX, special DESCA11 block placement
|
||||||
(if (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagNum 11))
|
(if (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagNum 11))
|
||||||
;; Keep Y tweak, but align X with other right-side VFD cables
|
(setq insPt (list (+ x 2.0) (+ y 0.5) 0.0))
|
||||||
(setq insPt (list (+ x xAdjust) (+ y 0.5) 0.0))
|
|
||||||
)
|
|
||||||
|
|
||||||
;; FIOM/FIOH right-side X normalization: align all DESCA10..16 to DESCA09
|
|
||||||
(if (and (>= tagNum mirrorThreshold)
|
|
||||||
(or (= blkName "PLCIO_ARMORBLOCK_FIOM") (= blkName "PLCIO_ARMORBLOCK_FIOH")))
|
|
||||||
(progn
|
|
||||||
(setq refAtt (getAttObj attList "DESCA09"))
|
|
||||||
(if refAtt
|
|
||||||
(progn
|
|
||||||
(setq refPt (vlax-get refAtt 'InsertionPoint))
|
|
||||||
(setq dx (- (car refPt) (car pt)))
|
|
||||||
(setq insPt (list (+ (car insPt) dx) (cadr insPt) (caddr insPt)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
;; Insert cable block
|
;; Insert cable block
|
||||||
@ -841,8 +732,9 @@
|
|||||||
(setBlockAttr newBlock "TAG1" taga)
|
(setBlockAttr newBlock "TAG1" taga)
|
||||||
(setCableDesc2 newBlock val2)
|
(setCableDesc2 newBlock val2)
|
||||||
|
|
||||||
; Mirror blocks on right side
|
; Mirror blocks for DESCA07 and above except special single DESCA11
|
||||||
(if (>= tagnum mirrorThreshold)
|
(if (and (>= tagnum mirrorThreshold)
|
||||||
|
(not (and (= blkName "PLCIO_ARMORPOWERFLEX") (= tagnum 11))))
|
||||||
(progn
|
(progn
|
||||||
(command "_MIRROR" newEnt "" insPt (list (car insPt) (+ (cadr insPt) 0.1)) "N")
|
(command "_MIRROR" newEnt "" insPt (list (car insPt) (+ (cadr insPt) 0.1)) "N")
|
||||||
(entdel newEnt)
|
(entdel newEnt)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user