Hey guys,
Its been a while...
I'm wondering if someone could help me add the ability to trim polylines in the below function.
We have a lisp-based P&ID program that hasn't been updated in a while. The P&ID users use this a lot.
I can't post the entire routine, but i can send it in an email if someone thinks they can help.
The routine lets the users insert a block from a toolbar and it will align the block to the line and then trim the inner portion.
The lines are always horizontal or vertical and the users always draw with SNAP turned on.
Each block is called similar to what is shown below where the; 1) Layer is set 2) Breaking function is called 3) block name (dwg) is called and 4) the size of the break is defined:
;;;Inline Strainer w/ Gate Valve
(defun c:H3_INLINE_STRAINER_GATE()
(layerSymbol)
(blockInsertInLine "H3_inline_strainer_gate" 0.18750)
);end Inline Strainer w/ Gate Valve
And the function "BlockInsertInline" is shown below:
;;;******************************************************************************
;;;Function : blockInsertInLine *
;;;******************************************************************************
;;;Description : 1. Inserts symbol *
;;; 2. Layer SYMBOL *
;;; 3. Scale 1 to 1 *
;;; 4. Breaks line and auto orients symbol *
;;; *
;;;******************************************************************************
(defun blockInsertInLine (blockName breakDistance)
;(defun blockInsertInLine ()
(insertSettings)
(insertScale)
(osModeOff)
(cleanFunctionStart)
(setq symbolName (strcat SYMBOL_DIRECTORY blockName ".dwg"))
(directoryCheck)
(if (/= nil (findfile symbolName)) ;block was found on network
(progn
(getInsertionPoint)
(setvar "osmode" 0)
(if (= selectedEntity nil) ;selected point was not on a line
(insertNoBreak) ;inserts without break
;else
(progn
(if (> breakDistance 0.0)
(progn
(setq ang nil)
(breakLine)
) ;end progn
;else
(setq ang nil)
) ;end if
(if (= ang nil)
(command ".insert" symbolName point1 scaleFactor scaleFactor pause)
;else
(command ".insert" symbolName point1 scaleFactor scaleFactor ang)
) ;end if
) ;end progn
) ;end if
(princ)
) ;end progn
) ;end if
;return object snap mode to existing state
(setvar "osmode" existOsMode)
(cleanFunctionEnd)
) ;end blockInsertInLine
;;;******************************************************************************
;;;Functions used by blockInsertInLine *
;;;******************************************************************************
;;;getInsertionPoint: gets insertion point *
;;;insertNoBreak: inserts symbol without breaking line *
;;;breakLine: determines angle of and breaks line *
;;;******************************************************************************
(defun getInsertionPoint ()
(command ".insert" symbolName pause (command))
(setq point1 (getvar "lastpoint"))
(setq selectedEntity (ssget point1))
) ;end getInsertionPoint
(defun insertNoBreak ()
(command ".insert" symbolName point1 "" "" pause)
) ;end insertNoBreak
; function to break line for symbol insertion
(defun breakLine ()
(setq entityName (ssname selectedEntity 0)) ;assign entity name of entity at selected point to en
(setq point2 (cdr (assoc 10 (entget entityName))))
(setq point3 (cdr (assoc 11 (entget entityName))))
(setq ang (rtd (angle point2 point3)))
(if (and (> ang 90)(<= ang 270))
(setq ang (- ang 180))
) ;end if
(setq breakPoint1 (polar point1 (angle point3 point2) breakDistance))
(setq breakPoint2 (polar point1 (angle point2 point3) breakDistance))
(command "break" entityName breakPoint1 breakPoint2)
) ;end breakLine
Note: Yes, I do know of Lee's Automatick Block Break available here
http://lee-mac.com/autoblockbreak.html but I would like to simply modify the existing code that we have to include polylines. Lee's routine is awesome but it would require a total reworking of the existing program.
Thank you
Any help is appreciated
~Greg