TheSwamp
CAD Forums => CAD General => Topic started by: jbaxter on December 20, 2006, 10:29:50 PM
-
Greetings,
I am searching for a match properties lsp routine which will simply pick a source polyline and then apply the same characteristics to another single or selection set of polylines, layer,width,color,linetype etc.
Regards,
John
-
Something like MATCHPROP ??
-
Been one of those weeks, huh John? I know the feeling. :-)
-
Yep, I am sure many drafties will sympathise with me.:-)
I do have the matchprop command however does not in particular match the polyline's width.
Regards,
JB
-
What version of ACAD? I'm pretty sure '05 and up does that (I can't remember)
-
Hi,
I am using LDD3.
Regards,
JB
-
Well aren't you just SOL?
I'll see if I can throw something together (unless someone else already has something they'd like to share) but I can't promise anything; not today anyways. Today is our annual Holiday Drink-Fest in the office!!
-
Is LDD3 based on the 2000 family? (2004 will match polyline widths.)
-
John,
No time, but here is a quickie.
No guarantees. :)
Merry Christmas
(defun C:mPOLY (/ colr ename ent i lay ltyp obj ss typ wid)
(if (setq ent (nentsel "\nSelect source polyline: "))
(progn
(setq obj (vlax-ename->vla-object (car ent))
typ (substr (vla-get-objectname obj) 5) )
(if (vl-position (strcase typ) '("POLYLINE" "2DPOLYLINE"))
(progn
(if (vl-catch-all-error-p
(setq wid (vl-catch-all-apply
'vla-get-ConstantWidth (list obj))))
(progn
(princ "\nWidth varies, setting to ")
(princ (setq wid 0))
)
)
(setq lay (vla-get-layer obj)
ltyp (vla-get-Linetype obj)
colr (vla-get-color obj)
)
(while
(progn
(prompt "\nSelect plines to change.")
(setq ss (ssget '((0 . "Polyline,LWpolyline"))))
(if (null ss)
(princ "\nNothing selected, Try again.")
)
)
)
(setq i -1)
(while (setq ename (ssname ss (setq i (1+ i))))
;; update plines
(setq obj (vlax-ename->vla-object ename))
(vla-put-ConstantWidth obj wid)
(vla-put-layer obj lay)
(vla-put-Linetype obj ltyp)
(vla-put-color obj colr)
)
) ; progn
(prompt "\nNot a polyline")
)
)
)
(princ)
)
-
Maybe this would be better.
Still not much testing
;; Match Polyline.lsp
;; CAB 01/08/2007
;; Honer Locked Layers
(defun C:mPOLY () (MatchPOLY nil))
;; Over ride locked layers
(defun C:mPOLYL () (MatchPOLY t))
;; Main function
;; match Properties
;; layer
;; linetype
;; global width
(defun MatchPOLY (UnLock / colr ename ent i
lay ltyp obj ss typ wid Locked
lokt doc FoundLocked Layers
)
(vl-load-com)
(if (setq ent (entsel "\nSelect source polyline: "))
(progn
(vla-startundomark
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
)
(if UnLock ; Unlock layers
(vlax-for lay (vla-get-layers doc)
(if (= (vla-get-lock lay) :vlax-true)
(progn
(setq lokt (cons lay lokt))
(vla-put-lock lay :vlax-false)
)
)
)
)
(setq obj (vlax-ename->vla-object (car ent))
typ (substr (vla-get-objectname obj) 5)
lay (vla-get-layer obj)
Layers (vla-get-Layers doc)
)
(if (and (vl-position (strcase typ) '("POLYLINE" "2DPOLYLINE"))
(= (vla-get-Lock (vla-Item Layers lay)) :vlax-false))
(progn
(if (vl-catch-all-error-p
(setq wid (vl-catch-all-apply 'vla-get-constantwidth (list obj)))
)
(progn
(princ "\nWidth varies, setting to ")
(princ (setq wid 0))
)
)
(setq ltyp (vla-get-linetype obj)
colr (vla-get-color obj)
)
(setq FoundLocked 0)
(if (/= locked :vlax-true)
(progn
(while
(progn
(prompt "\nSelect plines to change.")
(setq ss (ssget '((0 . "Polyline,LWpolyline"))))
(if (null ss)
(princ "\nNothing selected, Try again.")
)
)
)
(setq i -1)
(while (setq ename (ssname ss (setq i (1+ i))))
;; update plines
(setq obj (vlax-ename->vla-object ename))
(setq objlay (vla-get-layer obj))
(if (= (vla-get-Lock (vla-Item Layers objlay)) :vlax-true)
(setq FoundLocked (1+ FoundLocked))
(progn
(vla-put-constantwidth obj wid)
(vla-put-layer obj lay)
(vla-put-linetype obj ltyp)
(vla-put-color obj colr)
)
)
)
)
)
(if lokt ; relock layers
(foreach lay lokt
(vla-put-lock lay :vlax-true)
)
)
(if (not (zerop FoundLocked))
(prompt
(strcat "\nFound " (itoa FoundLocked) " objects on locked layers.")
)
)
(vla-endundomark doc)
) ; progn
(prompt "\nNot a polyline, or Locked layer.")
)
)
)
(princ)
)
-
JB,
just for interest, what does the help in LDD show for MATCHPROP ?
Here are some piccys from the AC2006 help.
I am bemused why the function is different in each application ... :?
-
Maybe this would be better.
Still not much testing
;; Match Polyline.lsp
;; CAB 12/24/2006............................
Hi,
Thanks all for your help, back to the grind on Monday so will give it a try then.
Kind Regards & Happy New Year,
JB
-
JB,
just for interest, what does the help in LDD show for MATCHPROP ?
Hi,
The help describes a lineweight toggle under settingd for the command but does not seem to operate, that is, it does not trnasfer the width feature from source to target.
Regards,
John
-
Maybe this would be better.
Still not much testing
;; Match Polyline.lsp
;; CAB 12/24/2006
;; Honer Locked Layers
(defun C:mPOLY () (MatchPOLY nil))
;; Over ride locked layers
(defun C:mPOLYL () (MatchPOLY t))
Hi,
I am getting the following when selecting the source, it IS a pline and not on a locked layer.
Regards,
JB
Command: mpoly
Select source polyline:
Not a polyline, or Locked layer.
-
Attach a sample drawing.
Which pline in the drawing are you trying to select?
-
I have just opened up a fresh blank screen, created a polyline with pline command and width of say 0.2 with pedit , spline smoothed it, and then created another polyline with width 0.0 and spline smoothed.
Next applied the mpoly routine however rejects the source polyline.
Regards,
John
-
John,
I updated the code. Copy & try it again.
-
Hi,
Where is the code? :-)
regards,
JB
-
http://www.theswamp.org/index.php?topic=14096.msg170503#msg170503
-
Thanks you. That worked a treat, appreciate your help with it.
Regards,
JB
-
You're quite welcome.
-
Just a suggestion, but how difficult would it be to automatically turn LINES into POLYLINES if they aren't already. You know how when you do a Pedit and it says "Object selected is not a polylineDo you want to turn it into one? <Y>"
Again, just a suggestion. :)
-
PEDITACCEPT, available in 2004+. Upgrade already! :-D
-
Just a suggestion, but how difficult would it be to automatically turn LINES into POLYLINES if they aren't already. You know how when you do a Pedit and it says "Object selected is not a polylineDo you want to turn it into one? <Y>"
Again, just a suggestion. :)
you know how much I'd love that? I don't even see the point of drawing a line anymore... plines are so much superior.
-
PEDITACCEPT, available in 2004+. Upgrade already! :-D
:lmao:
-
Must be a better way to convert a line but this will do for now.
;; Match Polyline.lsp
;; CAB 01/08/2007
;; Rev 3 02/09/2007
;; Convert LINES to plines when selected
(defun C:mPOLY () (MatchPOLY nil nil)) ; Honer Locked Layers
(defun C:mPOLYL () (MatchPOLY t nil)) ; Over ride locked layers
(defun C:mPOLY+ () (MatchPOLY nil t)) ; Honer Locked Layers & convert lines
(defun C:mPOLYL+ () (MatchPOLY t t)) ; Over ride locked layers & convert lines
;;=====================================================
;; Main function
;; match Properties -> layer, linetype, global width
;;=====================================================
(defun MatchPOLY (UnLock lflag / colr ename ent i
lay ltyp obj ss typ wid Locked
lokt doc FoundLocked Layers filter pt
elst objlay dellst
)
(vl-load-com)
(if UnLock
(setq pkFilter "_+.:E:S")
(setq pkFilter "_+.:E:S:L")
)
(if lflag
(setq filter '((0 . "Polyline,LWpolyline,Line")))
(setq filter '((0 . "Polyline,LWpolyline")))
)
(prompt "\nSelect pline to copy from.")
(if (setq ss (ssget pkFilter '((0 . "Polyline,LWpolyline"))))
(progn
(vla-startundomark
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
)
(if UnLock ; Unlock layers
(vlax-for lay (vla-get-layers doc)
(if (= (vla-get-lock lay) :vlax-true)
(progn
(setq lokt (cons lay lokt))
(vla-put-lock lay :vlax-false)
)
)
)
)
(setq obj (vlax-ename->vla-object (ssname ss 0))
typ (substr (vla-get-objectname obj) 5)
lay (vla-get-layer obj)
Layers (vla-get-Layers doc)
)
(if (= (vla-get-Lock (vla-Item Layers lay)) :vlax-false)
(progn
(if (vl-catch-all-error-p
(setq wid (vl-catch-all-apply 'vla-get-constantwidth (list obj)))
)
(progn
(princ "\nWidth varies, setting to ")
(princ (setq wid 0))
)
)
(setq ltyp (vla-get-linetype obj)
colr (vla-get-color obj)
)
(setq FoundLocked 0)
(while
(progn
(prompt "\n** Select plines to change. **")
(setq ss (ssget ":L" Filter)) ; ignore locked layers
(if (null ss)
(princ "\nNothing selected, Try again.")
)
)
)
(setq i -1)
(while (setq ename (ssname ss (setq i (1+ i))))
(if (and lflag (= (cdr (assoc 0 (setq elst (entget ename)))) "LINE"))
;; convert LINE to a LW pline
(progn
(foreach n '(-2 -1 0 5 100 102 300 330 331 350 360)
(while (assoc n elst)
(setq elst (vl-remove (assoc n elst) elst))
)
)
(setq elst (append '((0 . "LWPOLYLINE")(100 . "AcDbEntity")
(100 . "AcDbPolyline")) elst))
(setq pt (assoc 10 elst))
(setq elst (vl-remove pt elst))
(setq elst (append elst (list '(90 . 2) '(70 . 0) '(43 . 0.0)
'(38 . 0.0) '(39 . 0.0) pt '(40 . 0.0)
'(41 . 0.0) '(42 . 0.0))))
(setq pt (assoc 11 elst))
(setq elst (vl-remove pt elst))
(setq elst (append elst (list (cons 10 (cdr pt)) '(40 . 0.0)
'(41 . 0.0) '(42 . 0.0))))
(entmake elst)
(setq dellst (cons ename DelLst))
(setq ename (entlast))
)
)
;; update plines
(setq obj (vlax-ename->vla-object ename))
(setq objlay (vla-get-layer obj))
(if (= (vla-get-Lock (vla-Item Layers objlay)) :vlax-true)
(setq FoundLocked (1+ FoundLocked))
(progn
(vla-put-constantwidth obj wid)
(vla-put-layer obj lay)
(vla-put-linetype obj ltyp)
(vla-put-color obj colr)
)
)
)
(and DelLst (mapcar 'entdel DelLst))
(if lokt ; relock layers
(foreach lay lokt
(vla-put-lock lay :vlax-true)
)
)
(if (not (zerop FoundLocked))
(prompt
(strcat "\nFound " (itoa FoundLocked) " objects on locked layers.")
)
)
(vla-endundomark doc)
) ; progn
(prompt "\nNot a polyline, or Locked layer.")
)
)
)
(princ)
)
<edit: updated code>
-
you know how much I'd love that? I don't even see the point of drawing a line anymore... plines are so much superior.
In Civil-3D, the PLINE is a standard tool, used for all kinds of things. But it doesn't work for everything. With PLINE, the Z-value (elevation) of the pline is set by the first point in the PLINE, and then remains the same for every other point in the PLINE. So the first point in the PLINE will snap to the X,Y,Z of the point you select. But for the rest of the vertices, OSNAPing to points only takes the X and Y values from the OSNAP, and the Z value is the same as it was for the first vertex in the PLINE.
So for some things in C3D, I have to use 3DPOLY instead. For example, if I want to complete a survey figure (such as a sidewalk) so that it forms an enclosed area that I can hatch, I will use 3DPOLY on a no-plot layer to complete the figure, and snap both ends of the 3DPOLY to the survey figure(s). Then C3D can find a valid hatch boundary, and create the hatch.