Jump to content

Help! Draw double line with different line types and layers


fathihvac

Recommended Posts

Hello,

I need a lisp that draw a successive double line ,each line on different layer and with different line type.

for example :

*Line 1 is on layer: "liquid" ,ltype: "continous"

*Line 2 is on layer: "gas" ,ltype: "dashed"

Link to comment
Share on other sites

Think you can to create your special Multiline style,

just an idea

 

I agree, only thing to worry about is "Layer properties" , I think you can assign only Linetype and Color overrides but not specify the layer. So both lines will reside on 1 layer .unless the mline is exploded afterwards and a lisp code applies the properties.

 

Sans mulitline It would be an interesting code to write though :)

 

Prompt for "width".... [easy cheesy]

Depending on the number of pick points .... [would that be Line or Pline....]

Would be neat if you can dynamically see the second line..... [grdraw...]

.... what else... hmmmmn :shifty:...

Link to comment
Share on other sites

This will get you started I hope

(found it in my oldies)

 
; 11/13/04 4:06 PM
;Draw two lines;
(defun C:TWOLINES (/ *error* adoc cline cmde dia
erro mdsp osmd pbx pt ptlist rad )
;_____________________________;
(setq cmde (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_.undo" "_G")
(setq osmd (getvar "osmode"))
(setvar "osmode" 0)
(setq pbx (getvar "pickbox"))
(setvar "pickbox" 4)
(setq erro *error*)
(defun *error* (msg)
(setq *error* erro)
(setvar "osmode" osmd) 
(command "_.undo" "_E")
(setvar "cmdecho" cmde)
(setvar "pickbox" pbx) 
(if 
(or 
(= msg "Function cancelled")
(= msg "quit / exit abort") 
)
(princ)
(princ (strcat "\nError: " msg))
)
)

; Helper function

(defun safefill (lst ) 
(vlax-safearray-fill (vlax-make-safearray 
vlax-vbDouble
(cons 0 (- (length (apply 'append lst))1)))
(apply 'append lst))); eof safefill

(vl-load-com)
(setq adoc 
(vla-get-activedocument 
(vlax-get-acad-object))
mdsp (vla-get-modelspace adoc))
(setq dia (getreal "\nDiameter (or Wall Width): ") rad (/ dia 2.0))
(setq pt (getpoint "\nSpecify start point: "))
(setq ptlist (cons pt ptlist))
(while (setq pt1 (getpoint pt "\nSpecify next point: " ))
(grdraw pt pt1 1 -1)
(setq ptlist (cons pt1 ptlist))
(setq pt pt1)
)
(setq cline (vla-addPolyline mdsp (safefill ptlist)))
(vla-put-layer cline "liquid")
(vla-put-color cline 256)
;(vla-offset cline (- rad))
(vla-offset cline rad)

(vla-put-color cline 256)
(vla-put-layer cline "gas")
(vla-put-linetypescale cline dia);<-- to your suit
(vla-regen adoc acActiveViewport)
(princ)
(setq *error* erro)
(setvar "osmode" osmd)
(command "_.undo" "_E")
(setvar "cmdecho" cmde)
(setvar "pickbox" pbx)
(princ)
); eof 
(princ "\nStart command with \"TWOLINES\" ")
(princ)

 

~'J'~

Link to comment
Share on other sites

a quick and dirty code

 

(defun c:test  (/ pt1 pt2 ss width ang)
     (defun _otherline  (p1 ang w)
           (polar p1 (+ ang (/ pi 2.0)) w))
     (if (and
               (setq width (getdist "\nEnter Width: "))
       (setq pt1 (getpoint "\nPick point:")
             ptl (list pt1))
               pt1
               )
(progn          
     (while (setq pt2 (getpoint pt1 "\nNext point"))
           (setq ang (angle pt1 pt2))
           (grdraw pt1 pt2 7 1)
           (grdraw (_otherline pt1 ang width)
                   (_otherline pt2 ang width)
                   1
                   -1)
           (setq ptl (cons pt2 ptl)
                 pt1 pt2)
           )
     (setvar 'Clayer "liquid")
     (command
           "_Pline"
           (foreach
                  p
                   ptl
                 (command "_non" p))
           (command))
     (redraw)
     (command "_offset"
           width
           (entlast)
           "_non"
           (_otherline (car ptl) ang width)
           "")
     (command "_chprop" (entlast) "" "_layer" "Gas" "")))
(princ)
     )

Link to comment
Share on other sites

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...