If you are using saved circuits with the PLC I/O utility, you more than likely end up with a few wires that are not needed. There may also be times when you simply need to remove a wire from one side of a component.
Here is an example of how the saved circuits come in is inserted manually.
However when using the PLC I/O utility they look like this. The utility runs a wire to each terminal!
I decided to have the PLC I/O utility add a block named TRIMHERE on the wires we want removed. This is simply a dumb AutoCAD block with its insertion point directly on the wires that need to be trimmed.
A script is then run that records the insertion points of all TRIMHERE blocks. It then deletes the blocks and runs AETRIM at each of the recorded insertion points.
The script
(defun c:trimit ()
(vl-load-com)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(if
(setq ssBlks (ssget "_X" '((0 . "INSERT") (2 . "TRIMHERE"))))
(progn
(setq cnt (sslength ssBlks))
(repeat cnt
(setq entname (ssname ssBlks (setq cnt (1- cnt))))
(setq ent (entget entname))
(setq inspt (cdr (assoc 10 ent)))
(setq xy (strcat (rtos (car inspt))
","
(rtos (cadr inspt))
)
)
(setq cmd1 "AETRIM ")
(if (= 0 cnt)
(progn
(setq cmd2 (strcat xy "\r" "\r"))
)
(progn
(setq cmd2 (strcat xy "\r"))
)
)
(if (= (1- (sslength ssBlks)) cnt)
(progn
(vla-sendcommand adoc cmd1)
)
)
(vla-sendcommand adoc cmd2)
(entdel entname)
)
)
(princ "\n Error - No entities selected.")
)
)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.