Jump to content

Recommended Posts

Posted

Hello everyone, I am new to the forum and seeking a solution..

I have a number of thick polylines, and wanted to know if there is a way to outline the lines with smaller lines.. similar to the ink bottle tool in illustrator or flash, if you are familiar..

To illustrate further what I am referring..

A thick single polyline would have four thin lines places around its extent.

Anyone have an idea??

Posted

Wouldn't you have a problem plotting all these lines clearly? Jeez, five lines (polyline plus a total of four outside lines) seems like an awful lot. What are you depicting? A building wall?

Posted

Maybe something like this:

;;; Draw outline of polyline wall, based on constant width
;;; Required Subroutines: AT:SS->List, AT:List->Array, AT:List->SS
;;; Alan J. Thompson, 09.16.09
(defun c:Wall (/ *error* #Cmdecho #SSList #Choice #Space #Width #Off1
              #Off2 #Line1 #Line2
             )
 (vl-load-com)

;;; error handler
 (defun *error* (#Message)
   (and #Cmdecho (setvar "cmdecho" #Cmdecho))
   (and *AcadDoc* (vla-endundomark *AcadDoc*))
   (and
     #Message
     (or (member
           #Message
           '("console break" "Function cancelled" "quit / exit abort")
         ) ;_ member
         (princ (strcat "\nError: " #Message))
     ) ;_ or
   ) ;_ and
 ) ;_ defun

 (setq #Cmdecho (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (or *Acad* (setq *Acad* (vlax-get-acad-object)))
 (or *AcadDoc*
     (setq *AcadDoc* (vla-get-activedocument *Acad*))
 ) ;_ or
 (setq #Space (vla-get-modelspace *AcadDoc*))
 (vla-startundomark *AcadDoc*)
 (cond
   ((and (setq #SSList (AT:SS->List (ssget ":L" '((0 . "LWPOLYLINE"))) T))
         (not (initget 0 "Yes No"))
         (or (setq #Choice (getkword "\nDelete original? [Yes/No] <No>: "))
             (setq #Choice "No")
         ) ;_ or
    ) ;_ and
    (foreach x #SSList
      (if (and (not (vl-catch-all-error-p
                      (setq #Width (vl-catch-all-apply
                                     'vla-get-constantwidth
                                     (list x)
                                   ) ;_ vl-catch-all-apply
                      ) ;_ setq
                    ) ;_ vl-catch-all-error-p
               ) ;_ not
               (not (zerop #Width))
          ) ;_ and
        (progn
          ;; offsets
          (setq #Off1 (vl-catch-all-apply
                        'vla-offset
                        (list x (/ #Width 2))
                      ) ;_ vl-catch-all-apply
                #Off2 (vl-catch-all-apply
                        'vla-offset
                        (list x (/ #Width -2))
                      ) ;_ vl-catch-all-apply
          ) ;_ setq
          ;; convert to vla-objects
          (or (vl-catch-all-error-p #Off1)
              (setq #Off1 (car (vlax-safearray->list
                                 (vlax-variant-value #Off1)
                               ) ;_ vlax-safearray->list
                          ) ;_ car
              ) ;_ setq
          ) ;_ or
          (or (vl-catch-all-error-p #Off2)
              (setq #Off2 (car (vlax-safearray->list
                                 (vlax-variant-value #Off2)
                               ) ;_ vlax-safearray->list
                          ) ;_ car
              ) ;_ setq
          ) ;_ or
          ;; if error on either, delete and move on to next, otherwise, continue
          (if (or (vl-catch-all-error-p #Off1)
                  (vl-catch-all-error-p #Off2)
              ) ;_ or
            ;; delete
            (progn
              (vl-catch-all-apply 'vla-delete #Off1)
              (vl-catch-all-apply 'vla-delete #Off2)
            ) ;_ progn
            ;; continue
            (progn
              (setq #Line1 (vla-AddLightWeightPolyline
                             #Space
                             (AT:List->Array
                               (append
                                 (reverse
                                   (cdr (reverse
                                          (vlax-curve-getStartPoint #Off1)
                                        ) ;_ reverse
                                   ) ;_ cdr
                                 ) ;_ reverse
                                 (reverse
                                   (cdr (reverse
                                          (vlax-curve-getStartPoint #Off2)
                                        ) ;_ reverse
                                   ) ;_ cdr
                                 ) ;_ reverse
                               ) ;_ append
                             ) ;_ AT:List->Array
                           ) ;_ vla-AddLightWeightPolyline
                    #Line2 (vla-AddLightWeightPolyline
                             #Space
                             (AT:List->Array
                               (append
                                 (reverse
                                   (cdr
                                     (reverse (vlax-curve-getEndPoint #Off1)
                                     ) ;_ reverse
                                   ) ;_ cdr
                                 ) ;_ reverse
                                 (reverse
                                   (cdr
                                     (reverse (vlax-curve-getEndPoint #Off2)
                                     ) ;_ reverse
                                   ) ;_ cdr
                                 ) ;_ reverse
                               ) ;_ append
                             ) ;_ AT:List->Array
                           ) ;_ vla-AddLightWeightPolyline
              ) ;_ setq
              ;; join all together
              (if (zerop (getvar "peditaccept"))
                (vl-cmdf "_.pedit"
                         "_m"
                         (AT:List->SS (list #Off1 #Off2 #Line1 #Line2))
                         ""
                         "_y"
                         "_j"
                         ""
                         ""
                ) ;_ vl-cmdf
                (vl-cmdf "_.pedit"
                         "_m"
                         (AT:List->SS (list #Off1 #Off2 #Line1 #Line2))
                         ""
                         "_j"
                         ""
                         ""
                ) ;_ vl-cmdf
              ) ;_ if
              ;; set layer and width
              (vla-put-layer
                (vlax-ename->vla-object (entlast))
                (vla-get-layer x)
              ) ;_ vla-put-layer
              (vla-put-constantwidth
                (vlax-ename->vla-object (entlast))
                0
              ) ;_ vla-put-constantwidth
              ;; delete original, if #Choice = "Yes"
              (and (eq #Choice "Yes")
                   (vl-catch-all-apply 'vla-delete (list x))
              ) ;_ and
            ) ;_ progn
          ) ;_ if
        ) ;_ progn
      ) ;_ if
    ) ;_ foreach
   )
 ) ;_ cond
 (*error* nil)
 (princ)
) ;_ defun

You will need the following subroutines:

;;; Convert selection set to list of ename or vla objects
;;; #Selection - SSGET selection set
;;; #VLAList - T for vla objects, nil for ename
;;; Alan J. Thompson, 04.20.09
(defun AT:SS->List (#Selection #VlaList / #List)
 (and #Selection
      (setq #List (vl-remove-if
                    'listp
                    (mapcar 'cadr (ssnamex #Selection))
                  ) ;_ vl-remove-if
      ) ;_ setq
      #VlaList
      (setq #List (mapcar 'vlax-ename->vla-object #List))
 ) ;_ and
 #List
) ;_ defun

;;; Convert list of vla or ename objects to 1 selection set
;;; #SelectionList - list of vla or ename selections
;;; Alan J. Thompson, 05.07.09
(defun AT:List->SS (#SelectionList / #SSAdd)
 (setq #SSAdd (ssadd))
 (mapcar '(lambda (x)
            (if (eq (type x) 'VLA-OBJECT)
              (ssadd (vlax-vla-object->ename x) #SSAdd)
              (ssadd x #SSAdd)
            ) ;_ if
          ) ;_ lambda
         #SelectionList
 ) ;_ mapcar
 #SSAdd
) ;_ defun

;;; Convert Point List into Array
;;; #List - List of points to convert
;;; Alan J. Thompson, 09.16.09
(defun AT:List->Array (#List)
 (vlax-Make-Variant
   (vlax-SafeArray-Fill
     (vlax-Make-SafeArray
       vlax-vbDouble
       (cons 0 (- (length #List) 1))
     ) ;_ vlax-Make-SafeArray
     #List
   ) ;_ vlax-SafeArray-Fill
 ) ;_ vlax-Make-Variant
) ;_ defun

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...