Recent Posts

Pages: 1 ... 8 9 [10]
91
AutoLISP (Vanilla / Visual) / Re: Modifying Alignment to Profile View help
« Last post by MSTG007 on May 08, 2024, 12:59:15 PM »
I got another one for you within this. I was hoping to Select the Profile View to Grab the Alignment. However, with this setup, I have to pick the alignment first. Then it will select all the Civil3D PN parts and the PressureN Parts, and place them into the selected profile view. I was trying to use the original selection set and apply it to both these commands (AddNetworkPartsToProf, AddPressurePartsToProf). Not having much luck. Any ideas?



Code: [Select]
(defun c:PN2PV (/ add ss i e l d g lst s n alignEnt alignObj startSta endSta)
  (setq add (ssadd))
  (princ "\nSelect Alignment: ")
  (if (setq ss (ssget '((0 . "AECC_ALIGNMENT"))))
      (progn
        ;; If selection set is not empty
        (repeat (setq i (sslength ss))
          (setq e (ssname ss (setq i (1- i)))
                l (vlax-curve-getdistatpoint e (vlax-curve-getendpoint e))
                d (/ l 300.)
                g d
                lst nil)
          (repeat 300
            (setq lst (cons (vlax-curve-getpointatdist e g) lst)
                  g (+ g d)))
          (setq lst (append lst (list (vlax-curve-getstartpoint e))))
          (if (setq s (ssget "_F" lst '((0 . "AECC_STRUCTURE,AECC_PIPE,AECC_PRESSUREPIPE,AECC_FITTING,AECC_APPURTENANCE"))))
              (repeat (setq n (sslength s))
                (ssadd (ssname s (setq n (1- n))) add))))
       
        (sssetfirst nil add)
        (command "AddNetworkPartsToProf"))

          (if (setq s (ssget "_F" lst '((0 . "AECC_STRUCTURE,AECC_PIPE,AECC_PRESSUREPIPE,AECC_FITTING,AECC_APPURTENANCE"))))
              (repeat (setq n (sslength s))
                (ssadd (ssname s (setq n (1- n))) add))))

        (sssetfirst nil add)
        (command "AddPressurePartsToProf"))
     
      (princ "\nNo entities selected."))
  (princ))
92
AutoLISP (Vanilla / Visual) / Re: Check if clip is present in the drawing
« Last post by w64bit on May 08, 2024, 11:43:07 AM »
Thank you.
Is it possible, please, to add an alert when xclips are found?
93
AutoLISP (Vanilla / Visual) / Re: 3d polyline splitting
« Last post by ribarm on May 08, 2024, 09:53:53 AM »
And this code is opposite of splitting by adding vertices... It's called "diet3dps" like my latest with lwpolyline that I coded recently...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:diet3dps ( / *error* unique getvertices collinear-p group_collinear_pts cmd uf s in pl plx cf vl nvl gg )
  2.  
  3.  
  4.   (defun *error* ( m )
  5.     (while (= 8 (logand 8 (getvar (quote undoctl))))
  6.       (if command-s
  7.         (command-s "_.UNDO" "_E")
  8.         (vl-cmdf "_.UNDO" "_E")
  9.       )
  10.     )
  11.     (if uf
  12.       (if command-s
  13.         (command-s "_.UCS" "_P")
  14.         (vl-cmdf "_.UCS" "_P")
  15.       )
  16.     )
  17.     (if cmd
  18.       (setvar (quote cmdecho) cmd)
  19.     )
  20.     (if m
  21.       (prompt m)
  22.     )
  23.     (princ)
  24.   )
  25.  
  26.   (defun unique ( lst )
  27.     (if lst
  28.       (cons (car lst)
  29.         (unique
  30.           (vl-remove-if (function (lambda ( x ) (equal x (car lst) 1e-6)))
  31.             (cdr lst)
  32.           )
  33.         )
  34.       )
  35.     )
  36.   )
  37.  
  38.   (defun getvertices ( c / i p ptlst )
  39.     (setq i -1)
  40.     (while (<= (setq i (1+ i)) (vlax-curve-getendparam c))
  41.       (setq p (vlax-curve-getpointatparam c i))
  42.       (setq ptlst (cons p ptlst))
  43.     )
  44.     (reverse ptlst)
  45.   )
  46.  
  47.   (defun collinear-p ( p1 p p2 )
  48.     (and
  49.       (equal (distance p1 p2) (+ (distance p1 p) (distance p p2)) 1e-6)
  50.       (equal (angle p1 p2) (angle p1 p) 1e-6)
  51.       (equal (angle p1 p2) (angle p p2) 1e-6)
  52.     )
  53.   )
  54.  
  55.   (defun group_collinear_pts ( ptlst / a b c g gg )
  56.     (while ptlst
  57.       (setq a (car ptlst) b (cadr ptlst) c (caddr ptlst))
  58.       (while (and c (collinear-p a b c))
  59.         (if (not (vl-position a g))
  60.           (setq g (cons a g))
  61.         )
  62.         (if (not (vl-position b g))
  63.           (setq g (cons b g))
  64.         )
  65.         (if (not (vl-position c g))
  66.           (setq g (cons c g))
  67.         )
  68.         (setq ptlst (cdr ptlst))
  69.         (setq a (car ptlst) b (cadr ptlst) c (caddr ptlst))
  70.       )
  71.       (setq ptlst (cdr ptlst))
  72.       (if g
  73.         (setq gg (cons (reverse g) gg))
  74.       )
  75.       (setq g nil)
  76.     )
  77.     (reverse gg)
  78.   )
  79.  
  80.   (setq cmd (getvar (quote cmdecho)))
  81.   (setvar (quote cmdecho) 0)
  82.   (while (= 8 (logand 8 (getvar (quote undoctl))))
  83.     (if command-s
  84.       (command-s "_.UNDO" "_E")
  85.       (vl-cmdf "_.UNDO" "_E")
  86.     )
  87.   )
  88.   (if command-s
  89.     (command-s "_.UNDO" "_BE")
  90.     (vl-cmdf "_.UNDO" "_BE")
  91.   )
  92.   (if (= 0 (getvar (quote worlducs)))
  93.     (progn
  94.       (if command-s
  95.         (command-s "_.UCS" "_W")
  96.         (vl-cmdf "_.UCS" "_W")
  97.       )
  98.       (setq uf t)
  99.     )
  100.   )
  101.   (prompt "\nPick reference 3D polyline(s)...")
  102.   (if (setq s (ssget (list (cons 0 "POLYLINE") (cons -4 "<or") (cons 70 8) (cons 70 9) (cons -4 "or>"))))
  103.     (repeat (setq in (sslength s))
  104.       (setq plx (entget (setq pl (ssname s (setq in (1- in))))))
  105.       (if (= 9 (cdr (assoc 70 plx)))
  106.         (setq cf t)
  107.       )
  108.       (setq vl (getvertices pl))
  109.       (setq nvl vl)
  110.       (setq gg (group_collinear_pts nvl))
  111.       (foreach g gg
  112.         (setq g (cdr g) g (reverse (cdr (reverse g))))
  113.         (foreach p g
  114.           (setq nvl (vl-remove-if (function (lambda ( x ) (equal p x 1e-6))) nvl))
  115.         )
  116.       )
  117.       (if cf
  118.         (setq nvl (reverse (cdr (reverse nvl))))
  119.       )
  120.       (setq nvl (unique nvl))
  121.       (vl-cmdf "_.3DPOLY")
  122.       (foreach v nvl
  123.         (vl-cmdf "_non" v)
  124.       )
  125.       (if cf
  126.         (while (< 0 (getvar (quote cmdactive)))
  127.           (vl-cmdf "_C")
  128.         )
  129.         (while (< 0 (getvar (quote cmdactive)))
  130.           (vl-cmdf "")
  131.         )
  132.       )
  133.       (setq nvl nil cf nil gg nil)
  134.     )
  135.   )
  136.   (*error* nil)
  137. )
  138.  

HTH.
M.R.
94
AutoLISP (Vanilla / Visual) / Re: 3d polyline splitting
« Last post by ribarm on May 08, 2024, 09:16:36 AM »
Try this code...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:split3dpolyssegs ( / *error* getvertices unit d cmd uf s in plx pl vl a b dd n sd nvl k )
  2.  
  3.  
  4.   (defun *error* ( m )
  5.     (if uf
  6.       (if command-s
  7.         (command-s "_.UCS" "_P")
  8.         (vl-cmdf "_.UCS" "_P")
  9.       )
  10.     )
  11.     (while (= 8 (logand 8 (getvar (quote undoctl))))
  12.       (if command-s
  13.         (command-s "_.UNDO" "_E")
  14.         (vl-cmdf "_.UNDO" "_E")
  15.       )
  16.     )
  17.     (if cmd
  18.       (setvar (quote cmdecho) cmd)
  19.     )
  20.     (if m
  21.       (prompt m)
  22.     )
  23.     (princ)
  24.   )
  25.  
  26.   (defun getvertices ( c / i p plst )
  27.     (setq i -1)
  28.     (while (<= (setq i (1+ i)) (vlax-curve-getendparam c))
  29.       (setq p (vlax-curve-getpointatparam c i))
  30.       (setq plst (cons p plst))
  31.     )
  32.     (reverse plst)
  33.   )
  34.  
  35.   (defun unit ( v / d )
  36.     (if (not (equal (setq d (distance (list 0.0 0.0 0.0) v)) 0.0 1e-6))
  37.       (mapcar (function (lambda ( x ) (/ x d))) v)
  38.     )
  39.   )
  40.  
  41.   (setq d 0.7) ;;; initial setting - change to suit your needs ;;;
  42.  
  43.   (setq cmd (getvar (quote cmdecho)))
  44.   (setvar (quote cmdecho) 0)
  45.   (while (= 8 (logand 8 (getvar (quote undoctl))))
  46.     (if command-s
  47.       (command-s "_.UNDO" "_E")
  48.       (vl-cmdf "_.UNDO" "_E")
  49.     )
  50.   )
  51.   (if command-s
  52.     (command-s "_.UNDO" "_BE")
  53.     (vl-cmdf "_.UNDO" "_BE")
  54.   )
  55.   (if (= 0 (getvar (quote worlducs)))
  56.     (progn
  57.       (if command-s
  58.         (command-s "_.UCS" "_W")
  59.         (vl-cmdf "_.UCS" "_W")
  60.       )
  61.       (setq uf t)
  62.     )
  63.   )
  64.   (prompt "\nPick reference 3D polyline(s)...")
  65.   (if (setq s (ssget (list (cons 0 "POLYLINE") (cons -4 "<or") (cons 70 8) (cons 70 9) (cons -4 "or>"))))
  66.     (repeat (setq in (sslength s))
  67.       (setq plx (entget (setq pl (ssname s (setq in (1- in))))))
  68.       (setq vl (getvertices pl))
  69.       (while (setq b (cadr vl))
  70.         (setq dd (distance (setq a (car vl)) b))
  71.         (if (> (fix (/ dd d)) 0)
  72.           (setq n (fix (/ dd d)))
  73.           (setq n (fix (1+ (/ dd d))))
  74.         )
  75.         (setq sd (/ dd n))
  76.         (setq nvl (cons a nvl))
  77.         (setq k 0)
  78.         (repeat n
  79.           (setq nvl (cons (mapcar (function +) a (mapcar (function *) (unit (mapcar (function -) b a)) (list (* (setq k (1+ k)) sd) (* k sd) (* k sd)))) nvl))
  80.         )
  81.         (setq vl (cdr vl))
  82.       )
  83.       (setq a (car nvl))
  84.       (setq nvl (cdr nvl))
  85.       (if (not (vlax-curve-isclosed pl))
  86.         (setq nvl (cons a nvl))
  87.       )
  88.       (setq nvl (reverse nvl))
  89.       (vl-cmdf "_.3DPOLY")
  90.       (foreach v nvl
  91.         (vl-cmdf "_non" v)
  92.       )
  93.       (if (vlax-curve-isclosed pl)
  94.         (while (< 0 (getvar (quote cmdactive)))
  95.           (vl-cmdf "_C")
  96.         )
  97.         (while (< 0 (getvar (quote cmdactive)))
  98.           (vl-cmdf "")
  99.         )
  100.       )
  101.       (setq nvl nil)
  102.     )
  103.   )
  104.   (*error* nil)
  105. )
  106.  

Regards, M.R.
95
On both others and my BricsCAD installations v22 through v24, the status bar works intermittently but then becomes nonfunctional (or freezes). This occurs on less demanding design tasks containing only basic 2D elements with no external resource file references, of course, no 3D, point clouds, etc.

ISSUE
The coordinates display and buttons become unresponsive.

WORKAROUND
Only the workaround in the title, first minimizing and then maximizing the application window restores its functionality. We are on the Windows 11 OS.

QUESTIONS
1.) Has anyone experienced this issue?
2.) If so, how did you resolve it?

UPDATE
I updated the graphics driver. There was no change: the status bar issue remained.

See attached laptop specifications.

Thanks,

Clint
 
96
AutoLISP (Vanilla / Visual) / Re: Attribute Text Width
« Last post by MeasureUp on May 07, 2024, 11:17:55 PM »
There is nothing special in the drawing file or template.

My starting point is an example in the ActiveX section in HELP showed below.
I have no idea to redefine the "oML" in my case by given a title block "BLK-01" and an attribute "ATT-01" based on multi page drawing.

I'd like to learn this method.
Thanks.

Code: [Select]
(defun c:Example_TextManipulation()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
 
    ;; Define the leader points
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 14)))
    (vlax-safearray-fill points '(1 1 0
                                  1 2 0
                                  2 2 0
                                  3 2 0
                                  4 4 0
                                 )
    )
    (setq i 0)

    (setq modelSpace (vla-get-ModelSpace doc))
    (setq oML (vla-AddMLeader modelSpace points i))
   
    (vla-put-TextWidth oML 7.4)
)
97
Thank you Joe!  Working parallel circuitry and your code works great for locating minimum margins between two polyline objects.  Appreciated!
98
AutoLISP (Vanilla / Visual) / Re: 3d polyline splitting
« Last post by mariolino0099 on May 07, 2024, 05:56:33 AM »
Please can anyone help me ?
Thanks
99
AutoLISP (Vanilla / Visual) / Re: finding nested xrefs - AutoLISP
« Last post by Lee Mac on May 07, 2024, 05:03:23 AM »
Excellent, Lee. Thanks for sharing.

You're welcome  :-)

Curious, what is the order of the list that (_xrefhierarchy) returns? Is it random based on how tblnext finds the refs?

The order in which they are encountered in the block symbol table, in reverse (though, a simple sort could easily be applied).

Also, does it always list the "deepest" (child) references first, followed by any parent xrefs w child xrefs?

No - the list is merely the order in which they are encountered in the block symbol table; the nesting hierarchy is determined by recursively querying list items with multiple entries against the original list when printing the output.
100
AutoLISP (Vanilla / Visual) / Re: Attribute Text Width
« Last post by HOSNEYALAA on May 07, 2024, 03:44:56 AM »
can you  addition a sample dwg
Pages: 1 ... 8 9 [10]