Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/28/2021 in all areas

  1. That is a great effort, added a couple more good options like error check makes it more bullet proof, something I don't do often enough.
    1 point
  2. @BIGAL Since your comment is baiting me to do a better program - Here you go. This uses Lee's LM:Selectif function to filter and provide missed / invalid pick error handling. This could still be made better, but this is all I have time for (indeed I spent too much time on it already). EDIT: I realized the jump distance settings didn't make sense the distances have to be the same for an ARC, if different y, then use an ELLIPSE. EDIT2: Added a feature to combine the jump lines and arcs into a polyline. Doesn't work with the ellipses however. Also changed the behavior so that the gap distance specified is for the gap from the intersecting line to one side of the arc, not the total width of the arc. I did this because the gap width and jump height are now equivalent when the values are the same (i.e. rad to rad. - not dia. to rad.). EDIT3: Realized that I had a redundant IF statement after the main WHILE loop - removed. EDIT4: Simplified to always use an ARC - I don't know what I was thinking with the Ellipse version! Now will always work if you want to join the resulting lines. EDIT5: Added Error looping to make sure settings values are not invalid and allows the user to correct without re-entering the program. EDIT6: Added undo mark into error handler. Corrected local variables (removed ones no longer used and added one). (defun c:JumpLine (/ pick oldecho jump c0 c1 c2 c3 p0 ss res *error*) ; Load Visual LISP and start and undo mark (vl-load-com) (defun *error* (msg) (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*quit*,*exit*")) (princ (strcat "\nError: " msg "\n")) (princ "\nProgram Aborted.\n") ) (setvar "cmdecho" oldecho) (vla-EndUndoMark (vla-get-activedocument (vlax-get-acad-object))) (princ) ) (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object))) ; Get value of cmdecho sysvar and toggle it off. (setq oldecho (getvar "cmdecho")) (setvar "cmdecho" 0) ; Set global values. (if (not *jdx*)(setq *jdx* 0.125)) (if (not *jdy*)(setq *jdy* 0.125)) (setq pick T) (while (setq pick (LM:selectif "\nSelect Line to Break [Exit/Settings]: <Exit> " (lambda ( x ) (wcmatch (cdr (assoc 0 (entget (car x)))) "LINE,LWPOLYLINE")) entsel '("Exit Settings") ) ) (cond ((= pick "Settings") (setq jump 0.0) (While (= Jump 0.0) (setq jump *jdx*) (if (and (setq jump (getreal (strcat "\nSpecify Jump gap distance for both sides <" (rtos *jdx* 2 4) "> : "))) (> jump 0.0)) (setq *jdx* jump) (if (= jump 0.0)(princ "\nInvalid Value - must be greater than 0.")) ) ) (setq jump 0.0) (While (or (= Jump 0.0)(>= jump (* 2 *jdx*))) (setq jump *jdy*) (if (and (setq jump (getreal (strcat "\nSpecify Jump Height <" (rtos *jdy* 2 4) "> : "))) (> jump 0.0) (< jump (* 2 *jdx*))) (setq *jdy* jump) (cond ((= jump 0.0)(princ "\nInvalid Value - must be greater than 0.")) ((>= jump (* 2 *jdx*))(princ "\nInvalid Value - must be less than 2X the gap.")) ) ) ) ) (( = Pick "Exit")(setq pick nil)) ((and ( = (type pick) 'LIST)(= (type (car pick)) 'ENAME)) (setq ss (ssadd (car pick))) (while (setq c0 (getpoint "\nSpecify intersection: ")) (setq p0 (osnap (cadr pick) "_nea") c1 (polar c0 (angle p0 c0) *jdx*) c2 (polar c0 (angle c0 p0) *jdx*) c3 (polar c0 (+ (angle p0 c0) (/ pi 2)) *jdy*) ) (command "._break" pick "_f" "_non" c1 "_non" c2); break (command "._arc" "_non" c1 "_non" c3 "_non" c2) (setq p0 (polar c1 (angle p0 c0) *jdx*) ss (ssadd (entlast) ss) pick (nentselp p0) ss (ssadd (car pick) ss) ) ) (Initget "Yes No") (if (or (setq res (getkword "\n Join jumps into a polyline? [Yes/No] <Yes>: ")) (not res)) (command "._pedit" "_Multiple" ss "" "_yes" "_Join" "" "") ) ) ) ) (vla-EndUndoMark (vla-get-activedocument (vlax-get-acad-object))) (princ) ) ;;---------------------=={ Select if }==----------------------;; ;; ;; ;; Provides continuous selection prompts until either a ;; ;; predicate function is validated or a keyword is supplied. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; msg - prompt string ;; ;; pred - optional predicate function [selection list arg] ;; ;; func - selection function to invoke ;; ;; keyw - optional initget argument list ;; ;;------------------------------------------------------------;; ;; Returns: Entity selection list, keyword, or nil ;; ;;------------------------------------------------------------;; (defun LM:SelectIf ( msg pred func keyw / sel ) (setq pred (eval pred)) (while (progn (setvar 'ERRNO 0) (if keyw (apply 'initget keyw)) (setq sel (func msg)) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, Try again.") ) ( (eq 'STR (type sel)) nil ) ( (vl-consp sel) (if (and pred (not (pred sel))) (princ "\nInvalid Object Selected.") ) ) ) ) ) sel )
    1 point
  3. It shouldn't move, unless of course you have selected it as part of the selection in your stretch action. If you are sure it isn't selected then post your block so we can take look.
    1 point
  4. Hello If you are having trouble running StripMtext in AutoCAD 2021, please verify you have installed the AutoCAD 2021.1 update that was released in August 2020. This update fixes a bug in AutoLisp that broke the Vbscript RegEx object which StripMtext (and similar routines) use to find and remove formatting codes in a mtext. if after verifying you still are having trouble, then let me know and I’ll look into it. HTH, Steve Doman
    1 point
  5. I'm trying to export attributes to multiple csv files from dynamic blocks, have some code below someone already helped with but just have a slight problem I cannot fix, I have some blocks that are not being selected and others that are being ignored if they don't have all attributes currently visible that are in the foreach lines. I need all blocks included in the csv files, with blank cells if that attribute is currently not visible, block to be ignored only if none of the attributes in the foreach lines are currently visible. I have attached a DWG with some dynamic blocks inserted, these block names are not final, there will be more added with different block names. Code below, any help is appreciated. (Defun c:TripleCSV ( / _comma _Visible data ss i ev dp attb a b c folder opf csvfile) (setq _comma (lambda (lst)(substr (apply 'strcat (mapcar '(lambda (str) (strcat "," str) ) lst) ) 2 ) ) ) (defun _Visible (l) (Vl-remove-if '(lambda (atv) (zerop (car atv))) l)) (and (setq ReferenceNumber (strcase (getstring "\nEnter Reference Number: "))) (snvalid ReferenceNumber ) (setq data nil ss (ssget '((0 . "INSERT")(66 . 1)))) (repeat (setq i (sslength ss)) (setq ev (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (if (and (setq vp (Vl-some '(lambda (dy) (if (eq (Vlax-get dy 'PropertyName) "Lookup1") (Vlax-get dy 'Value))) (Vlax-invoke ev 'GetDynamicBlockProperties))) (setq attb (mapcar '(lambda (atb) (list (vlax-get atb 'Visible )(vla-get-tagstring atb) (Vla-get-textstring atb))) (Vlax-invoke ev 'GetAttributes) ) ) ) (setq data (cons (mapcar 'cdr (_Visible attb)) data )) ) ) (setq folder (acet-ui-pickdir (Getvar 'dwgprefix))) (setq data (vl-sort data '(lambda (n m) (< (cadr (assoc "ID_TAG" n)) (cadr (assoc "ID_TAG" m)) ) ) ) ) (foreach itm '(("_Devices" ("DEVICE_NUMBER" "DEVICE_TYPE" "PANEL_NUMBER" "PORT_NUMBER" "INPUT_NUMBER" "INPUT_TYPE" "OUTPUT_NUMBER" "OUTPUT_TYPE" )) ("_Inputs" ("DEVICE_NUMBER" "PANEL_NUMBER" "PORT_NUMBER" "INPUT_NUMBER" "INPUT_TYPE" )) ("_Outputs" ("DEVICE_NUMBER" "PANEL_NUMBER" "PORT_NUMBER" "OUTPUT_NUMBER" "OUTPUT_TYPE" )) ("_Panels" ("PANEL_TYPE" "PANEL_NUMBER" )) ) (setq opf (open (setq csvfile (strcat folder "\\" ReferenceNumber (Car itm) ".csv")) "w")) (write-line (_comma (setq taglst (Cadr itm))) opf) (Foreach val data (if (vl-every '(lambda (j)(assoc j val)) (Cadr itm)) (write-line (_comma (mapcar '(lambda (v) (cadr (assoc v val))) taglst)) opf) ) ) (close opf) (startapp "explorer" csvfile) ) ) (princ) ) Blocks.dwg
    -1 points
×
×
  • Create New...