Recent Posts

Pages: 1 [2] 3 4 ... 10
11
AutoLISP (Vanilla / Visual) / Re: Line between 2 endlines
« Last post by FS_AT12 on May 16, 2024, 12:20:28 PM »
Dear dexus,
Thank you for the link. I like the behaviour that you can select multiple lines at once, this accelerates the procedure.
I have tested it.
For me, it is not working, since the Lines in the architectural drawings are from "old buildings" based on measurements, none of the lines are parallel to each other, (just a very little number).
The lisp is not creating any line. -(
12
AutoLISP (Vanilla / Visual) / Re: Apply Plot style table to all layout
« Last post by Lonnie on May 16, 2024, 11:59:34 AM »
Added checking if the plot style exists.

I was messing with changing page setup when I saw this. Since this was played with today I thought why not?

Removed case sensitivity

Code: [Select]
(setq ctbLower (strcase ctb nil))
(setq installedPsLower (mapcar '(lambda (ps) (strcase ps nil)) installedPs))

Code: [Select]
(if (/= nil (vl-position ctbLower installedPsLower))


Code: [Select]
;;----------------------------------------------------------------------;;
;; setPlotStyle FUNCTION
;; https://www.theswamp.org/index.php?topic=45000.msg502065#msg502065
;; Added checking if the plot style exists by 3dwananb on 2024.05.15

(defun setPlotStyle (ctb / CurDoc installedPs ctbLower installedPsLower)
  ;; Get the active document
  (setq CurDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  ;; Get the list of installed plot styles
  (setq installedPs (vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames (vla-get-ActiveLayout CurDoc)))))

  ;; Convert the input plot style name and the list of installed plot styles to lowercase for case-insensitive comparison
  (setq ctbLower (strcase ctb nil))
  (setq installedPsLower (mapcar '(lambda (ps) (strcase ps nil)) installedPs))

  ;; Check if the specified plot style exists in a case-insensitive manner and set it
  (if (vl-position ctbLower installedPsLower)
    (progn
      (princ (strcat "\nPlot Style successfully set to: '" ctb "'\n"))
      (vlax-map-collection
        (vla-get-Layouts CurDoc)
        '(lambda (x) (vla-put-StyleSheet x ctb))
      )
    )
    (progn
      (princ (strcat "\nPlot Style '" ctb "' not found!\n"))
      ;; Print the available plot style tables if the specified plot style is not found
      (princ "\nAvailable plot style tables:\n")
      (mapcar '(lambda (ps) (princ (strcat ps ""))) installedPs)
    )
  ) ;; If plotstyle exists, set it; otherwise, print available plot styles.
)

;; Example invocation
(setPlotStyle "monochrome.ctb")



Before I did that I added the list of files to look at trying to figure out why it failed.

Code: [Select]
(setq CurDoc (vla-get-ActiveDocument (vlax-get-acad-object)))

Code: [Select]
(setq installedPs (vlax-safearray->list (vlax-variant-value (vla-GetPlotStyleTableNames (vla-get-ActiveLayout CurDoc)))))
13
AutoLISP (Vanilla / Visual) / Re: Line between 2 endlines
« Last post by ribarm on May 16, 2024, 11:54:35 AM »
If I understood correctly...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:connect_with_lines ( / curve1 curve2 pt1 pt2 pt3 pt4 )
  2.  
  3.  
  4.   (setq curve1 (car (entsel "\nSelect first curve: ")))
  5.   (setq curve2 (car (entsel "\nSelect second curve: ")))
  6.         pt2 (vlax-curve-getendpoint curve1)
  7.         pt3 (vlax-curve-getstartpoint curve2)
  8.         pt4 (vlax-curve-getendpoint curve2)
  9.   )
  10.   (if (< (distance pt2 pt3) (distance pt2 pt4))
  11.     (mapcar (function set) (list (quote pt3) (quote pt4)) (list pt4 pt3))
  12.   )
  13.   (command "_.line" "_non" (trans pt1 0 1) "_non" (trans pt3 0 1) "" "_.line" "_non" (trans pt2 0 1) "_non" (trans pt4 0 1) "")
  14.   (princ)
  15. )
  16.  

HTH.
14
AutoLISP (Vanilla / Visual) / Re: Line between 2 endlines
« Last post by dexus on May 16, 2024, 11:24:01 AM »
I use something similar to this written by Tharwat:
https://www.cadtutor.net/forum/topic/72563-autolisp-to-create-enclosed-polylines-from-parallel-lines/#comment-578774


If you want lines instead of closed polylines, you could explode the polylines at the end of the routine.
15
AutoLISP (Vanilla / Visual) / Line between 2 endlines
« Last post by FS_AT12 on May 16, 2024, 10:16:18 AM »
Hi
I am facing a problem with architectural drawings.
There are missing lines that I have to manually draw.

I have found a lisp that is basically doing the job but not at all. So I wanted to ask if anybody could help me to adapt this lisp with the following functions:

The lisp is asking for 2 Lines, and creates a new (closed) polyline connecting these 2 Lines, and deleting the selected 2 lines


I would need to change:
1: do not delete the source selected lines.
2: do not create a closed Polyline, just 2 Lines
3: the lisp is working just if the selected lines are LINES, is it possible that it is working with all kind of lines? Like POLYlLines, or Arcs or even Splines? Most important would be to work with Polylines, or even just the selected Polyline segments.


Code - Auto/Visual Lisp: [Select]
  1. (defun c:connectLines (/ line1 line2 data1 data2 pt1 pt2 pt3 pt4)
  2.   (and
  3.     (setq line1 (car (entsel "\nSelect first line: ")))
  4.     (= (cdr (assoc 0 (setq data1 (entget line1)))) "LINE")
  5.     (setq line2 (car (entsel "\nSelect second line: ")))
  6.     (= (cdr (assoc 0 (setq data2 (entget line2)))) "LINE")
  7.     (setq pt1 (cdr (assoc 10 data1))
  8.           pt2 (cdr (assoc 11 data1))
  9.           pt3 (cdr (assoc 11 data2))
  10.           pt4 (cdr (assoc 10 data2))
  11.     )
  12.     (or (< (distance pt2 pt3) (distance pt2 pt4))
  13.         (mapcar 'set '(pt3 pt4) (list pt4 pt3))
  14.     )
  15.     (command "_.erase"
  16.              (ssadd line2 (ssadd line1))
  17.              ""
  18.              "_.pline"
  19.              "_non"
  20.              (trans pt1 0 1)
  21.              "_non"
  22.              (trans pt2 0 1)
  23.              "_non"
  24.              (trans pt3 0 1)
  25.              "_non"
  26.              (trans pt4 0 1)
  27.              "_close"
  28.     )
  29.   )
  30.   (princ)
  31. )

https://stackoverflow.com/questions/47230782/draw-line-connecting-ends-of-2-parallel-lines-with-autolisp

It would be great if somebody could help me.



EDIT (John): 1. Fixed subject line spelling error. 2. Added code tags.
16
AutoLISP (Vanilla / Visual) / Re: Issue with Layout - Copy Command
« Last post by jnelson on May 16, 2024, 09:16:07 AM »
I'm copying the "Template" layout each time.
17
.NET / Re: Gems & other stuff ...
« Last post by MickD on May 16, 2024, 06:59:02 AM »
 :2funny:
18
.NET / Re: Gems & other stuff ...
« Last post by It's Alive! on May 16, 2024, 06:20:50 AM »
This is my favorite
19
.NET / Re: Gems & other stuff ...
« Last post by It's Alive! on May 16, 2024, 06:19:46 AM »
lol!
20
.NET / Re: Gems & other stuff ...
« Last post by MickD on May 16, 2024, 06:17:07 AM »
 :-)
Pages: 1 [2] 3 4 ... 10