Recent Posts

Pages: 1 [2] 3 4 ... 10
11
AutoLISP (Vanilla / Visual) / Re: Modify DWGUNITS
« Last post by ScottMC on Today at 09:55:58 AM »
With my ancient A2K, this works: (setvar "LUNITS" 2) <- for decimal
12
AutoLISP (Vanilla / Visual) / Re: [request] Radiant Pipe Layout
« Last post by JohnK on Today at 09:45:48 AM »
I know legal was on the meeting (didn't say much), but they did say something about "indemnity". But I wonder if our legal wanted a section of their EULA updated.
https://www.avenir-online.com/AvenirWeb/LoopCAD/LoopCADEULA.aspx

But I'm not sure how that even applies because it's just an application that produces output. We assume liability when we "send the final product out" (-i.e. it is up to us to verify the information is correct before we sign the drawings).

I got the impression that IT couldn't get answers about "security". I imagine questions like: "does it talk to the internet", "where/what/who", etc. and they wouldn't give an answer (or gave the wrong one).

The meeting was short and basically was telling me I may want to find an alternative.

13
AutoLISP (Vanilla / Visual) / Re: [request] Radiant Pipe Layout
« Last post by It's Alive! on Today at 09:21:07 AM »
I’m interested in what types of questions your organization would ask with regards to ‘security’ and ‘Legal’ things. 
I know I'm not setup for enterprise clients, I always thought, 500 seats and you get the source under NDA,
5 and I’d just say, sorry, I’m not setup for that.  :crazy2:
I guess the bigger companies are doomed to stall productivity with bureaucracies   
Could be a topic for another thread…
14
AutoLISP (Vanilla / Visual) / Re: [request] Radiant Pipe Layout
« Last post by JohnK on Today at 07:56:11 AM »
I just evaluated LoopCAD and put in a purchase request. It was denied because apparently, they would not even discuss "security" and other things with Legal and IT. My request was denied.
None of my business, but… what did they say? Like no answer or ..Go away or I shall taunt you a second time! 

I don't know either really, But I got the impression that they basically hung up the phone (so to speak). I got a lot of "They refuse", "I highly doubt", and "Do you have any other software ideas". 
15
Keep the blocks on the polyline and delete other blocks within the tolerance on both sides of the line

issue:

https://www.cadtutor.net/forum/topic/78798-selection-of-blocks-that-have-their-point-of-origin-in-a-polygon-avoiding-other-blocks-with-the-same-name-but-that-still-overlap-a-little-in-the-polygon/#comment-625827

Colleagues, best regards. Today I come to ask for help. I have developed a routine that splits a polygon based on the location of the origin of the blocks above it; However, the selection takes into account other blocks that overlap only slightly in the polygon, allowing me to run the routine anyway but with an undesired result.
I can remove the blocks manually, but when there are too many it becomes very tedious and time-consuming. I want to know if there is a way to avoid these external blocks that alter the results of my routine.
In the attached dwg I present 2 cases, in the one on the right the routine works without problems, however in the one on the left the complication occurs with the blocks external to the polygon but that still overlap a little.
Another complication that arises is when the polygon presents an arc.

=============================================

Code: [Select]
(defun c:xdtb_pl_tolerase (/ E typ blkname ss fence-box plane)
  (xd::doc:getdouble
    (xdrx-string-multilanguage
      "\n搜索范围"
      "\nSearch range tolerance"
    )
    "#xd-var-global-search-tol"
    (xd::doc:getpickboxheight)
  )
  (xd::doc:getdouble
    (xdrx-string-multilanguage
      "\n点线容差精度"
      "Point and line tolerance"
    )
    "#xd-var-global-tol-dist"
    (xdrx-getvar "equalpoint")
  )
  (if (and (setq e (car (xdrx-entsel
  (xdrx-string-multilanguage
    "\n拾取特征图元类型<退出>:"
    "\nPick feature entity type<Exit>:"
  )
)
   )
   )
   (setq typ (assoc 0 (entget e))
blkname (xdrx-getpropertyvalue e "name")
   )
   (setq ss (xdrx-ssget
      (xdrx-string-multilanguage
"\n选择多段线<退出>:"
"\nSelect Polyline<Exit>:"
      )
      '((0 . "*polyline"))
    )
   )
      )
    (progn
      (xdrx-begin)
      (mapcar
'(lambda (x)
   (if (and (setq fence-box (xdrx-getpropertyvalue
      x
      "tofence"
      #xd-var-global-search-tol
      1
    )
    )
    (setq fence-box (xdrx-getsamplept fence-box))
    (setq
      ss1 (ssget "cp"
fence-box
(list typ)
  )
      ss2 (ssget "f" (xdrx-getsamplept x) (list typ))
    )
       )
     (progn
       (setq nums  0
     plane (xdrx-getpropertyvalue x "plane" t)
       )
       (mapcar '(lambda (y)
  (setq position (xdrx-getpropertyvalue
   y
   "position"
)
closest (xdrx-getpropertyvalue
   x
   "getclosestpointto"
   position
)
position (xdrx-point-orthoproject position plane)
closest (xdrx-point-orthoproject closest plane)
  )
  (if (not (equal closest position #xd-var-global-tol-dist))
    (progn
      (setq nums (1+ nums))
      (xdrx-entity-delete y)
    )
  )
)
       (xdrx-ss->ents ss1)
       )
       (xdrx-prompt
(xdrx-string-formatex
   (xdrx-string-multilanguage
     "\n共删除了 %d 个容差范围内的不在多段线线上的图块."
     "\nA total of %d tiles matching the feature criteria were deleted."
   )
   nums
)
       )
     )
   )
)
(xdrx-ss->ents ss)
      )
      (xdrx-end)
    )
  )
  (princ)
)
16
In BricsCAD (ssget "_+.:E:S") does a single selection, acting like Entsel but will select everything under the cursor.

I also created the attached that does the same thing using a crossing polygon. The PICKBOXCOORD funtion returns a set of coordinates centred on the pick point and relative to the current pickbox size than can be used to define the crossing polygon.

Code - Auto/Visual Lisp: [Select]
  1. ;; PICKBOXCOORD
  2. ;; Pick Box Coordinates
  3. ;; Returns coordinates (list of 4 points defining a square) that are planar to the current display view, relative to the current pickbox size, and centred about the given point.
  4. ;; the given centre point must be in WCS
  5. ;; returned points are also in WCS
  6. ;; Includes an option to apply a scale factor to the current PICKBOX value.
  7. ;;
  8. ;; e.g for
  9. ;; (setvar 'PICKBOX 6) and in plan view
  10. ;; (PICKBOXCOORD (trans (getpoint) 1 0) 1)
  11. ;; ((72.0287613899495 74.940245442679 0.0) (72.0287613899495 75.8325809183257 0.0) (72.9210968655962 75.8325809183257 0.0) (72.9210968655962 74.940245442679 0.0))
  12. ;; (PICKBOXCOORD '(0 0 0) 1)
  13. ;; ((-0.446167737823339 -0.446167737823339 0.0) (-0.446167737823339 0.446167737823339 0.0) (0.446167737823339 0.446167737823339 0.0) (0.446167737823339 -0.446167737823339 0.0))
  14. ;; (PICKBOXCOORD '(0 0 0) 10)
  15. ;; ((-4.46167737823339 -4.46167737823339 0.0) (-4.46167737823339 4.46167737823339 0.0) (4.46167737823339 4.46167737823339 0.0) (4.46167737823339 -4.46167737823339 0.0))
  16.  
  17. (defun PickBoxCoord ( pctr factor / ratio pbox2)
  18.         ;;VIEWSIZE ; Current height of the viewport in drawing units
  19.         ;;SCREENSIZE ; x,y size of the viewport in pixels
  20.         (if (not factor) (setq factor 1))
  21.         (setq ratio (/ (getvar 'VIEWSIZE) (cadr (getvar 'SCREENSIZE)))) ; ratio between drawing units and pixels
  22.         (setq pbox2 (* (getvar 'PICKBOX) ratio 0.5 factor)) ; get 1/2 the current pickbox size in drawing units and apply factor if given
  23.         (setq pctr (trans pctr 0 2)) ; convert the given point to display coordinates
  24.         ;; Create a point list of each of the four corners
  25.         (mapcar '(lambda (pts) (trans pts 2 0))
  26.                         (list
  27.                                 (list (- (car pctr) pbox2) (- (cadr pctr) pbox2) (caddr pctr)) ; bottom left corner
  28.                                 (list (- (car pctr) pbox2) (+ (cadr pctr) pbox2) (caddr pctr)) ; top left corner
  29.                                 (list (+ (car pctr) pbox2) (+ (cadr pctr) pbox2) (caddr pctr)) ; top right corner
  30.                                 (list (+ (car pctr) pbox2) (- (cadr pctr) pbox2) (caddr pctr)) ; bottom right corner
  31.                         )
  32.         )
  33. )
  34.  

SSET Usage Example

Code - Auto/Visual Lisp: [Select]
  1. ;; PICKBOXSSET
  2. ;; Pick Box Selection Set
  3. ;; Creates a crossing box selection set based on the current pickbox size
  4. ;; relative to the given pick box centre point (in WCS)
  5. ;; returns a selection set if entities are found.
  6. ;; If not nil the factor will be applied to size of the current pickbox.
  7. ;;
  8.  
  9. ;; (PICKBOXSSET (trans (getpoint) 1 0) 1)
  10.  
  11. (defun PickBoxSSet ( pctr factor )
  12.         (ssget "_CP" (PICKBOXCOORD pctr factor))
  13. )

Test to visualise the selection box created by PICKBOXCOORD

Code - Auto/Visual Lisp: [Select]
  1. ;; DRAWPICK
  2. ;; Test of PICKBOXCOORD
  3. ;; Creates a 3DPOLY about the selected point
  4. ;; This should always be planar to the current display
  5.  
  6.  
  7. (defun C:DrawPick ( / pt gext coord)
  8.  (setq pt (getpoint "\nPick a point: "))
  9.  (cond (pt
  10.                         (setq pt (trans pt 1 0)) ; convert point to WCS
  11.                         (setq gext (PICKBOXCOORD pt 10))
  12.                                 (entmake
  13.                                                 (list
  14.                                                         '(0 . "POLYLINE")
  15.                                                         '(100 . "AcDbEntity")
  16.                                                         '(100 . "AcDb3dPolyline")
  17.                                                         '(70 . 9) ; 8 = 3DPOLY, 9 = Closed 3DPOLY
  18.                                                 )
  19.                                 )
  20.                                 (foreach coord gext
  21.                                         (entmake
  22.                                                 (list
  23.                                                         '(0 . "VERTEX")
  24.                                                         '(100 . "AcDbEntity")
  25.                                                         '(100 . "AcDbVertex")
  26.                                                         '(100 . "AcDb3dPolylineVertex")
  27.                                                         '(70 . 32)
  28.                                                         (cons '10 coord) ; Coordinate needs to be a list in the form (10 x y z)
  29.                                                 )
  30.                                         )                              
  31.                                 )
  32.                                 (entmake '((0 . "SEQEND")))
  33.                 )
  34.  )
  35.  (prin1)
  36. )
17
AutoLISP (Vanilla / Visual) / Re: "ssget everything" for a single point?
« Last post by xdcad on Today at 05:56:30 AM »
Provide an idea:

Erase completely overlapping (coincide) objects and keep one

https://www.theswamp.org/index.php?topic=59483.0

18
AutoLISP (Vanilla / Visual) / Make 3D Point from COGO Anonymous Block
« Last post by rayakmal on Today at 03:38:35 AM »
I'm trying to convert COGO Anonymous blocks to 3D Points, since all insertion point of these Anonymous blocks are (0,0,0), the Points I've got from the conversion are all have coordinate (0,0,*).
Anyone can help me with this code?

Code: [Select]

(defun C:TEST ( )

   (if (setq en (car (entsel "\n. Pick one Anonymous block: ")))
     (progn
       ;;
       ;; Get list of Texts inside block
       ;;
       (setq txtlst (GET-TxtLstFromAnonBlock en))
       ;; Pick one to Process
       (if (setq idx (LM:listbox-V12 " Select Elevation Data " txtlst 2))
          (setq idx (car idx))
       )
       (princ "\n. Select Block to Convert: ")
       (setq filter '(( 0 . "INSERT")))
       (setq sset (ssget filter))

       (setq counter    (sslength sset))
       (setq idxcounter 0)

       (while sset
         (setq enm  (ssname sset 0))
         (MakeCOGOPOINT enm idx)
         (setq sset  (ssdel enm sset))
         (if (zerop (sslength sset))
            (setq sset nil)
         );end if
         (setq idxcounter (+ idxcounter 1))
       );end of while

       (if (> counter 0)
         (princ (strcat "\n. Anonymous Blocks: "        (itoa counter)
                        " selected, " (itoa idxcounter)
                        " Processed"
                )
         )
       );end if

     );end progn
   );end if
   (setmode *mod2)
   (OldErrTrap)
   (princ)
)

(defun dxf-code (code enm /) (cdr (assoc code (entget enm))))

(defun GET-TxtLstFromAnonBlock (en)
  (if (AND (= (dxf-code 0 en) "INSERT") ;Check if it's an inserted block reference
           (= "*U" (substr (dxf-code 2 en) 1 2))
      )
    (progn
      (setq blkname (dxf-code 2 en)) ;Get the block's name from the Insert's DXF data
      (setq a  (tblobjname "BLOCK" blkname))

      (setq txlst '())
      (setq data (entget a))
      (while a
          (if (setq a (entnext a))
            (progn
               (setq etype (cdr (assoc 0 (entget a))))
               (if (= etype "MTEXT")
                   (progn
                      (setq txt (dxf-code 1 a))
                      (setq txlst (append txlst (list txt)))
                   );end progn
               );end if
            );end progn
          );end if
      );end while
     );end progn
  );end if
  txlst
)

(defun MakeCOGOPOINT ( en idx / blkname bn)

  (if (AND (= (dxf-code 0 en) "INSERT") ;Check if it's an inserted block reference
           (= "*U" (substr (dxf-code 2 en) 1 2))
      )
    (progn
      (setq blkname (dxf-code 2  en)) ;Get the block's name from the Insert's DXF data
      (setq ipt     (dxf-code 10 en))
      (setq a    (tblobjname "BLOCK" blkname))
      (setq data (entget a))

      (setq txlst '())
      (while a
          (if (setq a (entnext a))
            (progn
               (setq etype (cdr (assoc 0 (entget a))))
               (if (= etype "MTEXT")
                   (progn
                      (setq txt (dxf-code 1 a))
                      (setq txlst (append txlst (list txt)))
                   );end progn
               );end if
            );end progn
          );end if
       );end of while
       (setq txtelev (nth idx txlst))
       (if (Setq elev (distof txtelev))
          (command "Point" (mapcar '+ (2D-Of ipt)  (list 0.0 0.0 elev)))
       )
     );end progn
   );end if
);end defun

;; List Box  -  Lee Mac
;; Displays a DCL list box allowing the user to make a selection from the supplied data.
;; msg - [str] Dialog label
;; lst - [lst] List of strings to display
;; bit - [int] 1=allow multiple; 2=return indexes
;; Returns: [lst] List of selected items/indexes, else nil

(defun LM:listbox-V12 ( msg lst bit / dch des tmp rtn )
    (cond
        (   (not
                (and
                    (setq tmp (vl-filename-mktemp nil nil ".dcl"))
                    (setq des (open tmp "w"))
                    (write-line
                        (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select="
                            (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=25;}spacer;ok_cancel;}"       ;;; TINGGI ASALNYA 15
                        )
                        des
                    )
                    (not (close des))
                    (< 0 (setq dch (load_dialog tmp)))
                    (new_dialog "listbox" dch)
                )
            )
            (prompt "\nError Loading List Box Dialog.")
        )
        (   t     
            (start_list "list")
            (foreach itm lst (add_list itm))
            (end_list)
            (setq rtn (set_tile "list" "0"))
            (action_tile "list" "(setq rtn $value)")
            (setq rtn
                (if (= 1 (start_dialog))
                    (if (= 2 (logand 2 bit))
                        (read (strcat "(" rtn ")"))
                        (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")")))
                    )
                )
            )
        )
    )
    (if (< 0 dch)
        (unload_dialog dch)
    )
    (if (and tmp (setq tmp (findfile tmp)))
        (vl-file-delete tmp)
    )
    rtn
)

19
AutoLISP (Vanilla / Visual) / Re: [request] Radiant Pipe Layout
« Last post by It's Alive! on Today at 03:01:07 AM »
I just evaluated LoopCAD and put in a purchase request. It was denied because apparently, they would not even discuss "security" and other things with Legal and IT. My request was denied.
None of my business, but… what did they say? Like no answer or ..Go away or I shall taunt you a second time! 
20
AutoLISP (Vanilla / Visual) / Re: [request] Radiant Pipe Layout
« Last post by dexus on Today at 02:46:01 AM »
This topic isn't about this specific code, but I was intrigued to figure out what this string of code did.
But even with indentation some more variables would have been nice.
Code - Auto/Visual Lisp: [Select]
  1.   "_.pline" ; Start polyline
  2.  
  3.   (mapcar '+ ; First point of line segment
  4.     (polar ip 0.0 ls)
  5.     (list 0.0 (* r 2.0))
  6.   )
  7.  
  8.   (polar ; Second point of line segment
  9.     (mapcar '+
  10.       (polar ip 0.0 ls)
  11.       (list 0.0 (* r 2.0))
  12.     )
  13.     pi
  14.     lr
  15.   )
  16.  
  17.   "a" ; Arc
  18.   "s" ; second point of arc
  19.   (mapcar '+ ; Second point of arc
  20.     (polar
  21.       (mapcar '+
  22.         (polar ip 0.0 ls)
  23.         (list 0.0 (* r 2.0))
  24.       )
  25.       pi
  26.       lr
  27.     )
  28.     (list (- r) r)
  29.   )
  30.   (mapcar '+ ; end point of arc
  31.     (polar
  32.       (mapcar '+
  33.         (polar ip 0.0 ls)
  34.         (list 0.0 (* r 2.0))
  35.       )
  36.       pi
  37.       lr
  38.     )
  39.     (list 0.0 (* r 2.0))
  40.   )
  41.  
  42.   "l" ; Line
  43.   (polar ; next point of line segment
  44.     (mapcar '+
  45.       (polar
  46.         (mapcar '+
  47.           (polar ip 0.0 ls)
  48.           (list 0.0 (* r 2.0))
  49.         )
  50.         pi
  51.         lr
  52.       )
  53.       (list 0.0 (* r 2.0))
  54.     )
  55.     0.0
  56.     lr
  57.   )
  58.  
  59.   "a" ; Arc
  60.   "s" ; second point of arc
  61.   (mapcar '+ ; second point of arc
  62.     (polar
  63.       (mapcar '+
  64.         (polar
  65.           (mapcar '+
  66.             (polar ip 0.0 ls)
  67.             (list 0.0 (* r 2.0))
  68.           )
  69.           pi
  70.           lr
  71.         )
  72.         (list 0.0 (* r 2.0))
  73.       )
  74.       0.0
  75.       lr
  76.     )
  77.     (list r r)
  78.   )
  79.   (mapcar '+ ; End point of arc
  80.     (polar
  81.       (mapcar '+
  82.         (polar
  83.           (mapcar '+
  84.             (polar ip 0.0 ls)
  85.             (list 0.0 (* r 2.0))
  86.           )
  87.           pi
  88.           lr
  89.         )
  90.         (list 0.0 (* r 2.0))
  91.       )
  92.       0.0
  93.       lr
  94.     )
  95.     (list 0.0 (* r 2.0))
  96.   )
  97.   "" ; End of polyline
  98. )
Pages: 1 [2] 3 4 ... 10