hello
i want help for creating lisp for me please ... the lisp will do these functions
1- as the attached image if i have block with yellow at right and some green blocks
2- i want when i launch the lisp to ask me to draw poly line that i want as in image 2
3- after that when i draw this path with polyline and press enter the lisp ask me to choose blocks that i want to connect to this polyline and i will choose one by one or multiple blocks then after choosing the blocks and press enter ... the lisp will offset the main polyline that i draw and connect every polyline with the basepoint of the blocks that i choose sequentially as appear in this image (attached DWG)
can anyone help me please
Solved! Go to Solution.
Solved by ŠeekeeCZ. Go to Solution.
Solved by ŠeekeeCZ. Go to Solution.
Solved by calderg1000. Go to Solution.
The lisp you provide for specific blocks called MDB and ddddd if i want to use lisp with another blocks i should go and write in the attached file but the lisp i provide no need to do this it works with any block with any name ... You can try yourself
@onlineoffers1988 wrote:
The lisp you provide for specific blocks called MDB and ddddd if i want to use lisp with another blocks i should go and write in the attached file but the lisp i provide no need to do this it works with any block with any name ... You can try yourself
I would guess that if you replace the names with asterisks, you'll get what you wanted.
attached the fix
specific block selection is removed (the mess it can cause is on you š) prompts changed.
Lighting Fixtures not in perpendicular to Leading path connect with diagonal for manually fix. there is no guarantee this will work in all cases. for me on your sample drawing it works perfect.
enjoy
moshe
thanks ... but unfortunately ... the lines are still interfering ... offset works but all lines that at upper side have no spacing all above each other š i suggest the offest should be in both sides not in one side this may cause this problem
Also look in the dwg some of the blocks are not at z=0 which can cause problems they were at like 1.2335e-15. What I posted works with any block, yes its not auto but still way faster than manual.
maybe the osnap was doing this? attached lswire.vlx with osnap off
works š
Moshe
Hallelujah!
Your effort pays off š
if you still did not done it, mark this as your solution give credit to others that gave you help here.
have a nice day mate
Moshe
well, have my reasons why the code should be kept disclosed this time and you should be respecting that.
if in the coming future some modification will be needed i'm here and will be happy to fix.
Moshe
I respect your opinion ... Thanks for you ... But really i can't use your lisp in vlx version ... Please for all members at this forum... Can anyone edit my code and do my edits that i mentioned in this topic ??
Regards @onlineoffers1988
True something similar to what you require @hak_vz , already did. In an automated way with just one selection. You just have to take your time to search.
For the moment edit your code to get something similar to what you require. Of course, it is just an idea that can be improved much more.
Please follow the selection procedure explained in the video.
;;https://www.cadtutor.net/forum/topic/21484-i-search-for-offset-with-same-value-and-opposite-direction/#comment-175406
(defun c:HomeRun ( / MyLineSS of MyBlockSS BlockSelected acount side offset myline mln mypoints)
;;Edit for Calderg1000, 20-11-22
;;Undo
(defun *error* ( msg )
(and undo (vla-EndUndomark doc))
(or
(wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
)
(princ)
)
;;;-------------------------------------------------------------------------------------
;; Loop layers selection
;;Select Route
(princ "\nSelect Home Run Route ")
(setq MyLineSS (ssget "_+.:E:S" '((0 . "*LINE") ) ))
(command "_.fillet" "_polyline" (entlast));;----------------------------------nnn
;;Get Offset
;;(setq of 2.5) ; default offset, 2.5. Maybe work out as fraction of line length
(setq of (getdist "\nSpecify Distance between Lines: ")) ; User selects distance
;;Get blocks
;;Select Route
(princ "\nSelect one Block from every circuit ")
(setq MyBlockSS (ssget '((0 . "INSERT"))))
(setq BlockSelected (sslength MyBlockSS) )
;; Do Offset
(setq acount 1) ;; 1 so that it draws correct no of lines
(setq side 1)
(while (< acount (sslength MyBlockSS))
;;; (setq offset (* acount of side) )
(setq offset of)
(setq VlaOb (vlax-ename->vla-object (ssname MyLineSS ( - acount 1))))
(vla-offset VlaOb offset ) ;; offset line 1
(setq MyLineSS (ssadd (entlast) MyLineSS)) ;; add offset to selection set
(command "_.fillet" "_polyline" (entlast));;;------------------------------nnn
;;; (setq side (* side -1))
(setq side (* side 1))
(setq acount (+ acount 1))
) ; end while
;;; (setq MyLine (ssname MyLineSS 0))
(setq acount 0)
(setq MyPoints (list))
(while (< acount (sslength MyBlockSS))
(setq MyPoints (append MyPoints (list (cdr (assoc 10 (entget (ssname MyBlockSS acount))))) ))
(setq acount (+ 1 acount))
)
(repeat(setq i(sslength MylineSS))
(setq mln(ssname MylineSS (setq i(1- i))))
(setq myline(cons mln myline))
)
;;; (setq myline(reverse myline))
(perp2ent myline MyPoints)
;;Finish
(vla-EndUndoMark doc)
(princ)n
);;defun
;;;-------------------------------------------------------------------
(defun perp2ent (Myline MyPoints / acount pt lt ptp ang)
(setq acount 0)
(while (< acount (length MyPoints))
(setq pt (nth acount MyPoints))
(setq lt (nth acount Myline))
(setq ptp (vlax-curve-getClosestPointTo lt (trans pt 1 0)))
(setq ang (angle pt ptp))
(if
(or (= ang 0) (= ang (* 0.5 pi)) (= ang (* 1.5 pi)))
(progn
(entmake (list '(0 . "LINE")
(cons 10 (trans pt 1 0))
(cons 11 ptp)
) ;_ list
) ;_ entmake
;;;----------------------------------------
(command "_.break"
(ssadd lt)
(vlax-curve-getClosestPointTo lt (trans pt 1 0))
"@"
)
(command "erase" (entlast) "")
(setq acount (+ acount 1))
) ;progn1
;;;----------------------------------------
(progn
(entmake (list '(0 . "LINE")
(cons 10 (trans pt 1 0))
(cons 11 (list (car pt) (cadr ptp))) ;_ list
)
)
(entmake (list '(0 . "LINE")
(cons 10 (list (car pt) (cadr ptp)))
(cons 11 ptp)
) ;_ list
)
(command "_.break"
(ssadd lt)
(vlax-curve-getClosestPointTo lt (trans pt 1 0))
"@"
)
(command "erase" (entlast) "")
(setq acount (+ acount 1))
;;;---------------------------------------
) ;progn2
) ;if
) ;_ while
(princ)
)
Carlos Calderon G
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
i already tested this lisp before but the lisp has a lot of errors at various drawings ... i test the lisp you mention again now at some complicated drawings also has the same problems (as ex. hard to follow route that mentioned at some complicated drawings & no connection between lines ... just break and erase ) ... i really search more and do my best to reach that i want but till now the solution that work 99% well is the lisp by Moshe-A but i don't need vlx formatting ... thank you for your effort
@onlineoffers1988 Good Morning
@onlineoffers1988 wrote:I respect your opinion ... Thanks for you ... But really i can't use your lisp in vlx version ... Please for all members at this forum... Can anyone edit my code and do my edits that i mentioned in this topic ??
i though about it again and you are absolutely right and yesterday i eFax Autodesk Inc that i can not use AutoCAD\AutoLISP without their source code + Microsoft for Word\Excel\Outlook. until they reply, enjoy this update i solve the problem with the exceptional Lighting Fixtures (no diagonals)
have a nice day š
Moshe
thank you for your reply and your edits ... works well š ... i'm waiting for Autodesk replying ... waiting lsp file š
have a nice day
Now for the serious things, i think you should raise your hands up and say Dear Lord thank you and to this forum for i could come here place my request and other gave me a free solution when other are paying for such. the issue you placed was not another small lisp to play with but a very serious case that took me many days and sleepless nights to solve. so accept what you already have and be happy.
Moshe
Dear @Moshe-A i really appreciate your great effort, thanks god and thanks for all forum's members ... but let me explain with example what i feel now ...
If you were in a desert and you were very thirsty...and suddenly you found the water you wanted and saw it already pouring in front of your eyes and you were sure that it was drinkable water, but you were sure that there was a wall of glass between you and the water that prevented you from drinking that spilled water...what would you feel? Would you be happy... This is how I really feel right now, without exaggeration
thank you
have a nice day
You are not exaggerating? ha???
you over exaggerating and over dramatic. grow up man, this is not a life an death case. if you so badly want this, its a free market, turn to someone who will write it for you and pay and i'm not offering mine.
Moshe
Can't find what you're looking for? Ask the community or share your knowledge.