Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/13/2022 in all areas

  1. if you select a line that is set to ByLayer you need to pull the line type from the layer. or you will update all lines and polylines in the drawing that are bylayer. You need a list of layers that have the same linetype to make a 2nd selection of all lines and polylines on those layers that are set to bylayer. Doesn't have error checking so if you select text or something that doesn't have linetype or linetypescale it will error ;;----------------------------------------------------------------------;; ;; Update linetype scale (defun C:match-linetype (/ SS ent lay typ scl laylst) (setq i 0) (if (setq SS (ssget "_+.:E:S")) (progn (setq ent (vlax-ename->vla-object (ssname SS 0))) (setq lay (vla-get-layer ent)) (if (eq (setq typ (vla-get-linetype ent)) "ByLayer") (setq typ (vla-get-linetype (vlax-ename->vla-object (tblobjname "layer" lay)))) ) (setq scl (vla-get-linetypescale ent)) (setq SS (ssget (list '(0 . "LINE,*polyline") (cons 6 typ)))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-put-linetypescale (vlax-ename->vla-object ent) scl) (setq i (1+ i)) ) (vlax-for layer (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object))) (if (eq (vla-get-linetype layer) typ) (setq laylst (cons (vla-get-name layer) laylst)) ) ) (setq laylst (l2s "," laylst)) (if (setq SS (ssget "_CP" (mapcar 'cadr (cdr (assoc -1 (ssnamex SS)))) (list '(0 . "LINE,*polyline") '(6 . "ByLayer") (cons 8 laylst)))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (vla-put-linetypescale (vlax-ename->vla-object ent) scl) (setq i (1+ i)) ) ) ) ) (prompt (strcat "\n" (rtos i 2 0) " Entities updated")) (princ) ) ;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/list-to-string/m-p/830688/highlight/true#M56346 (defun l2s (delim lst / out) (setq out (car lst) lst (cdr lst)) (repeat (length lst) (setq out (strcat out delim (car lst)) lst (cdr lst)) ) out )
    2 points
  2. (command "_BREAK" (car (entsel "\nSelect Entity")) (getpoint "\nBreak at point") "@")
    1 point
  3. AutoCAD is trying to process a nil selection set. it doesn't error in BricsCAD Added a if statement to the 2nd ssget so it shouldn't run that code if nothing is selected.
    1 point
  4. why i try and stick with shorter command names or have a shortcut like (defun C:ColorOffsetV31 ... ) (defun C:COV31 () (C:ColorOffsetV31)) ;only calls longer code ---edit you might also like this option for picking a color. (if (eq (setq ansColor (acad_truecolordlg 30)) nil) ;acad_colordlg for just the 256 types (setq ansColor 250)) )
    1 point
  5. im using BricsCAD so im getting issues when using anything other than "_IMAGEATTACH", i've added the getpoint line in but it keeps skipping over it like it isnt there, i think its something to do with the dialog not closing once, the "okay" it pressed. all code: ;; Read CSV - Lee Mac ;; Parses a CSV file into a matrix list of cell values. ;; csv - [str] filename of CSV file to read (defun LM:readcsv (csv / des lst sep str) (if (setq des (open csv "r")) (progn (setq sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) ( ",") ) ) (while (setq str (read-line des)) (setq lst (cons (LM:csv->lst str sep 0) lst)) ) (close des) ) ) (reverse lst) ) ;; CSV -> List - Lee Mac ;; Parses a line from a CSV file into a list of cell values. ;; str - [str] string read from CSV file ;; sep - [str] CSV separator token ;; pos - [int] initial position index (always zero) (defun LM:csv->lst (str sep pos / s) (cond ((not (setq pos (vl-string-search sep str pos))) (if (wcmatch str "\"*\"") (list (LM:csv-replacequotes (substr str 2 (- (strlen str) 2)))) (list str) ) ) ((or (wcmatch (setq s (substr str 1 pos)) "\"*[~\"]") (and (wcmatch s "~*[~\"]*") (= 1 (logand 1 pos))) ) (LM:csv->lst str sep (+ pos 2)) ) ((wcmatch s "\"*\"") (cons (LM:csv-replacequotes (substr str 2 (- pos 2))) (LM:csv->lst (substr str (+ pos 2)) sep 0) ) ) ((cons s (LM:csv->lst (substr str (+ pos 2)) sep 0))) ) ) (defun LM:csv-replacequotes (str / pos) (setq pos 0) (while (setq pos (vl-string-search "\"\"" str pos)) (setq str (vl-string-subst "\"" "\"\"" str pos) pos (1+ pos) ) ) str ) (defun JH:insert-mapping (reference) (unload_dialog dlg_id) (setq NE (strcat (apply 'strcat reference) "NE") NW (strcat (apply 'strcat reference) "NW") SE (strcat (apply 'strcat reference) "SE") SW (strcat (apply 'strcat reference) "SW") symbol (substr NE 1 2) ) (setq pt (getpoint "\nInsertion point")) (setq scale 5000) (setq rotation 0) (if (findfile (setq NEpath (strcat "X:\\3. Event TM Plans\\Mapping\\data\\" symbol "\\" NE ".tif"))) (progn (command "_IMAGEATTACH" NEpath pt scale rotation) ) ) ) (defun JH:reference-finder (postcode / data) (setq upper (strcase postcode) lower (strcase postcode T) second-char (substr lower 2 2) third-char (substr lower 2 2) fourth-char (substr lower 2 2) num (atoi second-char) ) ;check to see if the second character is a number or not (if (= num 1) (setq csv-name (substr lower 1 1)) (setq csv-name (substr lower 1 2)) ) (if (and (setq f (strcat "C:\\BricsCAD Scripts\\MACROS\\CSV\\" (strcase csv-name) ".csv")) (setq data (LM:readcsv f)) ) (progn (if ;check if string is correctly formatted (setq reference (cdr (assoc upper data))) (JH:insert-mapping reference) (princ "Please enter a valid postcode in the correct format. For example: \"DN15 7PQ\"") ) ) (princ "Please enter a valid postcode in the correct format. For example: \"DN15 7PQ\"") ) (princ) ) (princ) (defun c:POSTCODE () (if (setq fn (findfile "MACROS\\DIALOGS\\POSTCODE.dcl")) (setq dlg_id (load_dialog fn)) (alert "Dialog POSTCODE.dcl not found") ) (new_dialog "PostcodeDia" dlg_id) (action_tile "postcode-search" "(JH:reference-finder $VALUE)") (start_dialog) (princ) )
    1 point
  6. Maybe use a selection set filter to select lines to change:: (ssget "_X" '((0 . "*LINE")(8 . "-LAYER-")(6 . "--LINETYPE-")(62 . "-COLOUR-")))
    1 point
  7. @AM-AP Look: (defun C:ColorOffsetV31 vs. ^C^CColorOffsetV031
    1 point
  8. it keeps skipping over it, I've tried it in a few places in the script but doesn't actually pop up. I probably just need a re-write because as it is everything is slung together I don't usually use "commands" so I'm pretty much clueless with them, with other scripts I stick to vla- (probably why im having none stop issues with them haha)
    1 point
  9. I managed to get it working, it was the "getpoint" and the "and" part in the if statement causing me issues so i'e changed this part to: (if (findfile (setq NEpath (strcat "X:\\3. Event TM Plans\\Mapping\\data\\" symbol "\\" NE ".tif"))) (progn (command "_IMAGEATTACH" NEpath "G" "E") ) ) but im now having a issue trying to insert at a specific mouse location i've only managed to get it working with using the geo ref as well im having issues trying to get all 4 tif images into the file
    1 point
  10. i broke the if statement down, it passes past the "true" and goes straight to the "false" part which prints the "NEpath" this prints out: "X:\3. Event TM Plans\Mapping\data\SE\SE80NE.tif" - which is the correct path (if (and (findfile (setq NEpath (strcat "X:\\3. Event TM Plans\\Mapping\\data\\" symbol "\\" NE ".tif"))) (setq pt (getpoint "\nInsertion point")) ) (progn (command "IMAGE" "-point" "_non" pt "-insert" NWpath) (setq tif (vlax-ename->vla-object (entlast))) (vla-getboundingbox tif 'minpt 'maxpt) (setq LL (vlax-safearray->list minpt) UR (vlax-safearray->list maxpt) LR (list (car UR) (cadr LL)) UL (list (car LL) (cadr UR)) ) ) (princ NEpath) ) i've tried writing the path without the formulas same issue, i tried xrefing images into CAD using the exact same printed path and it works fine. ill keep trying to break the code down, im just so confused with it all and why it can't find the file
    1 point
  11. the NEpath printed the is correct path, i used the exact same path to manually xref the .tif in, ive also just tried the path as a string with no varibales/ formulas and im getting the same issues. i've checked the path a handful of times to make sure its correct but everytime it cant seem to find the file
    1 point
  12. Are you sure the background color is just a see through color when printing, if you make the infill white it will print as Black. Do you want no color maybe redo the block and use wipeout. Post a dwg so can see what is going on.
    1 point
  13. When you pick 1st block you can get all the properties like insertionpoint, scale and rotation. So you may need a look up matching the 1st block with second block and the insertion point offset adjustment. (setq ent (entget (car (entsel "\nPick 1st block ")))) (setq ins (cdr (assoc 10 ent)) ang (cdr (assoc 50 ent)) bname (cdr (assoc 2 ent)) ) ; work out new insert point and rotation (command "-insert" bname2 s 1 newins newrot)
    1 point
  14. If your happy going back to old fashioned pop menu can be done very simply using notepad to make a mnu. You just group your parts under a common name in the menu, the image menu supports next and previous so can have more than 25 images. If you don't want a menu you can make custom dcl's also that load a group of images.
    1 point
  15. In the image below the UCS icon shows world coordinates. The block is dimensioned on a plane parallel to the ZX plane. Its Extrusion Direction DXF group code 210 is 0,-1,0. The text is oriented to be read by a vector point in the negative Y direction. The second block shows the result of changing the 210 code to (0.5744,-0.5744,0.5744) a vector perpendicular to an isometric viewing angle (0.5744 ~ sqrt(3)) . Note the change in all the dimension graphics as well as the value of the dimension as the dimension points are projected to a different plane. The third block is the result of exploding the dimension and rotating the text by -30° about an axis perpendicular to the viewing plane and the repositioning it. I'd try to live with the text on the plane of the dimension.
    1 point
×
×
  • Create New...