Recent Posts

Pages: [1] 2 3 ... 10
1
Hello,
        I wonder if there is a way with lisp code to create FeatureLine from Alignment something like this "(vlax-invoke flines 'addfrompolylineex obj style)" - this is to create FL from polyline. If anyone knows where I can read about methods like addfrompolylineex will be helpful too.
2
AutoLISP (Vanilla / Visual) / Extract Default Page Setup Error
« Last post by RayG2261 on Today at 10:11:26 AM »
Greetings- as promised in my Intro Post- I am curious about this routine. I am trying to figure a way to extract the Default Page Setup for multiple dwg files in a directory. It is not available in any Data Extraction command in Acad. Yes, I have a lsp setup in the acaddoc that will delete old Page Setups and bring in the correct Setups from a standard dwg located on the Network. I also have a routine that I use in ScriptPro that will set a particular Page Setup to multiple dwgs in a directory. However- on occasion, if we receive a file from a vendor or similar, or a rogue block contains an oddball Page Setup it can change the default Setup. So... I have asked around (mostly in that Cad Managers FB page) to see if anyone knew of such a routine. I basically got the suggestions that I listed above: acaddoc, Template stuff, etc... But that isn't what I was looking for. And using the ScriptPro takes 10-30 seconds per dwg to go through the routine. I just want to pick a list of dwgs, get the Default Page Setup, open the file and change the default. As I said, I am in no way a lsp'er, so I took the plunge into ChatGPT and asked if it could write one. The first effort was a disaster, btw. I rephrased the second attempt and did get something of a result. It opened up a file window, DID allow me to choose a file (not multiple), but it returned the "Too Many Arguments" error. That means nothing to me, other than it doesn't work. In a nutshell, I would like to be able to pick multiple files and have it generate a list (txt is fine) of the default Page Setups. (I hope I don't get shunned for using the ChatGPT thingee) Thanks...

Here is what ChatGPT wrote:

(defun c:ExtractPageSetup ()
  (setq dwglist (getfiled "Select drawings to extract page setup" "" "dwg" 4))
  (if dwglist
    (progn
      (setq pageSetupList nil)
      (foreach dwg dwglist
        (setq doc (vla-open (vla-get-documents (vlax-get-acad-object)) dwg))
        (setq layout (vla-get-layouts doc))
        (setq count (vla-get-count layout))
        (setq pageSetups '())
        (vlax-for lyt layout
          (if (= (vla-get-Objectname lyt) "AcDbLayout")
            (progn
              (setq name (vla-get-name lyt))
              (setq pageSetup (vla-get-PageSetup lyt))
              (setq pageSetups (cons (list name pageSetup) pageSetups))
            )
          )
        )
        (setq pageSetupList (cons (cons dwg pageSetups) pageSetupList))
        (vla-close doc)
      )
      (setq outFile (getfiled "Save page setup data to" "" "txt" 1))
      (if outFile
        (progn
          (setq outF (open outFile "w"))
          (foreach dwgData pageSetupList
            (setq dwg (car dwgData))
            (write-line (strcat "Drawing: " dwg) outF)
            (setq pageSetups (cdr dwgData))
            (foreach ps pageSetups
              (setq name (car ps))
              (setq setup (cdr ps))
              (write-line (strcat "Layout: " name) outF)
              (write-line (strcat "Paper size: " (vla-get-Papersize setup)) outF)
              (write-line (strcat "Plot origin: " (strcat (rtos (car (vla-get-Plotorigin setup))) 2 2) ", " (strcat (rtos (cadr (vla-get-Plotorigin setup)) 2 2))) outF)
              (write-line (strcat "Plot rotation: " (rtos (vla-get-Plotrotation setup)) 2 2) outF)
              (write-line "" outF)
            )
          )
          (close outF)
          (alert "Page setup data extracted successfully.")
        )
      )
    )
  )
  (princ)
)
3
If you have VLIDE open, you can go to Debug > Abort Evaluation; otherwise, try Ctrl+C.
4
CAD General / lisp ssget on script not working
« Last post by MarioR on Today at 02:49:25 AM »
Hello,

i will use an lisp "ssget" for script ('#' == space on lineend):
Code: [Select]
_explode (ssget "_X" '((0 . "INSERT")))#
On normal commandline it works, but in script is not working.

why?

regards Mario
5
AutoLISP (Vanilla / Visual) / Breaking an infinite Loop other than ctrl-alt-del.
« Last post by damn on June 13, 2024, 09:06:54 PM »
Damn!

I'm stuck in a loop, haven't for saved 1.5hrs stupid me....yeah yeah, save early save often.  I don't want to lose my latest updates.
Any other way other than ctrl-alt-del?

Damn.
6
Hi. I  update the code to select automatic more than one polylines in layer1. I test it and work fine but in this example  give me this error (look the dwg file)

Code: [Select]
Error: incorrect type - nil
Can any one help?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:changeInsidePolys (/ EDATA LSTPOLSINSIDE POLSS SSPOLSINSIDE VPOL VTX)
  2.   (if
  3.     (setq Polss (ssget "_X" '((0 . "LWPOLYLINE") (8 . "layer1") (70 . 1))))
  4.     (progn
  5.       (foreach pl (vl-remove-if 'listp (mapcar 'cadr (ssnamex Polss)))
  6.         (setq edata (entget pl))
  7.         (setq vtx (massoc 10 edata))
  8.         (setq ssPolsInside
  9.           (ssget "CP"
  10.             vtx
  11.             '((0 . "LWPOLYLINE") (8 . "layer2") (70 . 1))
  12.           )
  13.         )
  14.         (setq LstPolsInside
  15.           (vl-remove-if 'listp (mapcar 'cadr (ssnamex ssPolsInside)))
  16.         )
  17.         (foreach pol LstPolsInside
  18.           (if (and (inside_p (mu:centroide (setq vpol (massoc 10 (entget pol))))
  19.               vtx
  20.             )
  21.             (setq  ssPolsInside
  22.               (ssget  "WP"
  23.                 vpol
  24.                 '((0 . "*TEXT") (8 . "layer3"))
  25.               )
  26.             )
  27.           )
  28.             (progn
  29.               (if (= (tblsearch "layer" "BLD") nil)
  30.                 (command "_layer" "_m" "BLD" "_c" "10" "" ""))
  31.               (vla-put-layer (vlax-ename->vla-object pol) "BLD")
  32.               (vla-put-layer
  33.                 (vlax-ename->vla-object (ssname ssPolsInside 0))
  34.                 "BLD"
  35.               )
  36.             )
  37.           )
  38.         )
  39.       )
  40.     )
  41.       (prompt (strcat "\n No layer1 found."))
  42.   )
  43.   (princ)
  44. )
  45.  


Thanks
7
XDRX-API / Re: [XDrX-PlugIn(169)] Search Outlines
« Last post by domenicomaria on June 13, 2024, 05:45:43 AM »
I said this because in the examples it seems that there are only straight lines...
... very well !
8
XDRX-API / Re: [XDrX-PlugIn(168)] Search Regions
« Last post by domenicomaria on June 13, 2024, 05:44:32 AM »
I said this because in the examples it seems that there are only straight lines...
... very well !
9
XDRX-API / Re: [XDrX-PlugIn(169)] Search Outlines
« Last post by xdcad on June 13, 2024, 04:53:27 AM »
only with straight lines ?

(xdrx-geom-searchoutline ss)
Arbitrary curve, INSERT, hatch, region,mpolygon

above code:

'((0 . "*line,arc"))
10
XDRX-API / Re: [XDrX-PlugIn(168)] Search Regions
« Last post by xdcad on June 13, 2024, 04:51:32 AM »
only with straight lines ?

(xdrx-geom-searchregions ss)
Arbitrary curve, INSERT, hatch, region,mpolygon

above code:

'((0 . "*line,arc"))
Pages: [1] 2 3 ... 10