Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

convert pline to match layer lineweight

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
tracidennis
768 Views, 9 Replies

convert pline to match layer lineweight

We receive titleblock dwgs from clients that control lineweights via layers. We plot by color. I need an easy way to convert the lines to plines that = the layer lineweight. I modiied some free code (I'm very amature) but am missing something. It does what I want except will only works on the first line selected. Need help filling in the blanks.

 

Thanks 

 

 

(DEFUN C:glw (/ lw p obj)
(setvar "cmdecho" 1)
(setq P (ssget));Get what I want to change!
(SETQ OBJ (ENTSEL "PICK OBJECT TO MATCH LINEWEIGHT"));select object with desired lineweight!
(vl-load-com)
(vlax-for layer (vla-get-Layers
                (vla-get-ActiveDocument
                (vlax-get-acad-object)
))
(setq lw (vla-get-lineweight layer)))
(COMMAND "pedit" "m" P "" "y" "w" lw "")
(prin1))

 

 

9 REPLIES 9
Message 2 of 10
Lee_Mac
in reply to: tracidennis

Try the following:

 

(defun c:glw ( / ent lwt sel var val )
    (if
        (and
            (setq sel (ssget "_:L" '((0 . "LINE,ARC,LWPOLYLINE"))))
            (setq ent (car (entsel "\nSelect object to match lineweight: ")))
        )
        (progn
            (setq var '(cmdecho peditaccept)
                  val  (mapcar 'getvar var)
                  lwt  (cdr (assoc 370 (entget (tblobjname "layer" (cdr (assoc 8 (entget ent)))))))
            )
            (mapcar 'setvar var '(0 1))
            (command "_.pedit" "_m" sel "" "_w" (/ (if (< lwt 0) (getvar 'lwdefault) lwt) 100.0) "")
            (mapcar 'setvar var val)
        )
    )
    (princ)
)

 

Message 3 of 10
tracidennis
in reply to: tracidennis

Thanks a million. It works great. Will save a lot of time. Looks like I would have never gotten it to work with your help. Most appreciated.

Message 4 of 10
tracidennis
in reply to: tracidennis

Would I be pushing my luck to see if I can get this same routine except to get the lineweight of a line. I tried changing #tblobjname "layer"# to #tblobjname "line"# but it did not like it.

Thanks

Message 5 of 10
dbroad
in reply to: tracidennis

If you are going to round trip the drawings back to your consultant for further revisions, you will have ended up damaging the file by making these changes so that layer settings no longer have control over display.  I suggest that you make very minor changes to your plot styles and layer settings by asking your consultant for his plot style.  Look at it and add the settings to your plot styles.  If you are thinking about changing lines, arcs, and circles to polylines just so you can add widths that mimic thicknesses, you could destroy other built-in intelligence that depends on hidden handle data.

 

As a long time user of color based plotting, I finally admitted the advantages of using the lineweight settings of layers. I thought to myself, "I've got many years of color based plot settings in all my files so how could I make the change?" It was remarkably easy though.  You probably have many layers that you use all the time.  Write a command to add the lineweights to match the colors into those layers.  Then change either the definitiion for your plot style or choose another standard plot style.  Having a plot style that plots with object lineweights simplifies the whole process. I initially set all lineweights to "bylayer" and set each layer to its historical, color based lineweight. Every now and then, I still use polyline global widths but rarely need to resort to that.

 

To get started, work with changing your templates.  You will never go back to color based plotting once you switch.

Architect, Registered NC, VA, SC, & GA.
Message 6 of 10
tracidennis
in reply to: tracidennis

We do not send files back. We are a sub to multiple clients and our titleblocks needs to plot the same as theirs. The clients usually don't send the plot tables so we have to manually edit the lines. Thanks

Message 7 of 10
tracidennis
in reply to: tracidennis

Finally. I made a routine that will convert the line to a pline with the lineweight.

 

Thanks

Message 8 of 10
Lineabove
in reply to: tracidennis

Please share.

 

Message 9 of 10
Lee_Mac
in reply to: tracidennis

Try this:

 

(defun c:glw ( / ent sel var val )
    (if
        (and
            (setq sel (ssget "_:L" '((0 . "LINE,ARC,LWPOLYLINE"))))
            (setq ent (car (entsel "\nSelect object to match lineweight: ")))
        )
        (progn
            (setq var '(cmdecho peditaccept)
                  val  (mapcar 'getvar var)
            )
            (mapcar 'setvar var '(0 1))
            (command "_.pedit" "_m" sel "" "_w" (/ (getlwt (entget ent)) 100.0) "")
            (mapcar 'setvar var val)
        )
    )
    (princ)
)
(defun getlwt ( enx / lwt )
    (setq lwt (cdr (assoc 370 enx)))
    (cond
        (   (= -3 lwt) (getvar 'lwdefault))
        (   (<= 0 lwt) lwt)
        (   (<= 0 (setq lwt (cdr (assoc 370 (entget (tblobjname "layer" (cdr (assoc 8 enx)))))))) lwt)
        (   (getvar 'lwdefault))
    )
)
(princ)

 

Message 10 of 10
tracidennis
in reply to: tracidennis

;;;convert line with lineweight to pline

 

(DEFUN C:clw (/ PEA OBJ Lw cv)

(setvar "cmdecho" 0)
(setq pea (getvar "PEDITACCEPT"))
(setvar "PEDITACCEPT" 1)
(SETQ OBJ (ENTSEL "Pick LINE to convert to PLINE"))
(SETQ Lw (CDR (ASSOC 370 (ENTGET (CAR OBJ)))))
(IF (= Lw NIL) (SETQ Lw "BYLAYER"))
(setq cv (/ lw 2500.0));convertion
(if (not (tblsearch "layer" "E-ANNO-TTLB"));load layer
(command "-layer" "m" "E-ANNO-TTLB" "c" "5" "" ""));make layer
(COMMAND "pedit" obj "w" cv "")
(COMMAND "CHANGE" "l" "" "P" "LA" "E-ANNO-TTLB" "")
(setvar "PEDITACCEPT" pea)
(PRINC))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost