TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mohan on July 24, 2022, 12:06:23 PM
-
Help to make a route for the below Image
When I choose Initget & select the polyline it should change.
-
- You can use the ActiveX offset method (https://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-50EF273A-7552-4D6B-8523-BB956334D08A) to perform the offsets (a double offset example can be found here (http://lee-mac.com/doubleoffset.html)).
- You can change the global width using DXF group 43 or the ActiveX ConstantWidth property (https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-5632AA9B-0225-4D6A-84F1-3677E220779B)
-
Is the line work plines and lines ?
Should the new offset lines be added or original erased ?
What layers ?
What colors ?
It would not be hard to do something in lisp.
(http://)
-
Choose layers like example Main route, Sub route & Local route, (I can also change as per my requirement later)
All of them are Polyline
Original should not erase. (Attached Image)
-
Try this
; http://www.theswamp.org/index.php?topic=57731.0
; multi offset plines by Alanh July 2022
(defun c:coloroffs ( / ans obj obj2 col1 col2 off1 off2w )
(vl-load-com)
(if (not AH:Butts)(load "Multi radio buttons.lsp")) ; loads the program if not loaded already
(if (= ahdef nil)(setq ahdef 1)) ; this is needed to set default button
; you can reset default button to user pick
(setq ans (ah:butts ahdef "V" '("Please choose " "Main" "Sub" "Local" ))) ; ans holds the button picked value as a string
(setq ahdef but)
(cond
((= ans "Main")(setq off1 3.5 off2w 2.0 cent 5.0 col1 7 col2 1))
((= ans "Sub")(setq off1 2.5 off2w 1.5 cent 3.0 col1 7 col2 50))
((= ans "Local")(setq off1 1.5 off2w 1.0 cent 1.5 col1 7 col2 92))
)
(setq obj (vlax-ename->vla-object (car (entsel "Pick pline "))))
(vlax-put obj 'color col1)
(vlax-put obj 'constantWidth cent)
(vla-offset obj off1)
(setq obj2 (vlax-ename->vla-object (entlast)))
(vlax-put obj2 'color col2)
(vlax-put obj2 'constantWidth off2w)
(vla-offset obj (- off1))
(setq obj2 (vlax-ename->vla-object (entlast)))
(vlax-put obj2 'color col2)
(vlax-put obj2 'constantWidth off2w)
(princ)
)
-
Try this
That was amazing ! Thank you so much. . . :smitten:
-
If these lines are already layered this could be optimized for a selection set rather than picking one at a time.
Also, why not just make a different linetype for each of these to differentiate them?
-
I have tried for Multiple selection but still more to do ! :sick:
(if (setq sel
(ssget ":L" '
((0 .
"LWPOLYLINE") (100 .
"AcDbPolyline") (8 .
"-TEXT"))))
-
I have tried for Multiple selection but still more to do ! :sick:
(if (setq sel
(ssget ":L" '
((0 .
"LWPOLYLINE") (100 .
"AcDbPolyline") (8 .
"-TEXT"))))
Your filter is only grabbing polylines on a "-TEXT" layer?
-
Choose layers like example Main route, Sub route & Local route, (I can also change as per my requirement later)
All of them are Polyline
Original should not erase. (Attached Image)
I think you should be using the Map 3D toolset (https://knowledge.autodesk.com/support/autocad-map-3d/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/MAP3D-Use/files/GUID-DA811D26-6A38-45B9-B746-DE05A9F985C9-htm.html?st=About%20GIS%20Features) that comes with AutoCAD. What you're trying to do is called GIS. The different line styles can be styled using Map's tools. You can have complex line styles like you want. That's how all GIS is done.
-
Like ronjonp you can use a filter "main,sub,local" for the layers then get each pline and check the layer so where I ask is "main" etc just use a check what layer instead.
Please confirm your layer names, then all can be done in one go. Can do select an object get its layer name but use "Main" as line style.