Thursday, April 5, 2012

Auto Trim Wires from the PLC I/O Utility

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.
image However when using the PLC I/O utility they look like this. The utility runs a wire to each terminal!
image

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.
image

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    

<<Download the script here>>

(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.")
)
)

A HUGE shout out to Jim Bish of IMAGINiT for writing this script for me.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.