Jump to content

Keegan

Recommended Posts

hello

i want help for creating lisp for me please ... the lisp will do these functions

1- as the attached image (1a) 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 2a

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 5a (attached DWG)

can anyone help me please

5a.png

2a.png

1a.png

sample.dwg

  • Dislike 1
Link to comment
Share on other sites

So what do you know about LISP, how much of this problem have you solved yourself?

 

There was a couple of questions this week about offsetting line, this one 

asks to offset lines and then it makes a selection set out of the new lines - might be something you can modify. For example draw your route, select the fixings and count them - then you know how many times you need to offset your line.

 

There are LISPS out there that will give you the coordinate of the nearest point on a line to a block, that could be something to look for. You could use that to draw a line from your block to the centre line - you might need to work out if all the lines are orthogonal or some at angles. Either way it is possible.

 

Finally you might then want to search for a LISP that gives the distance along a polyline to a point on it. Use the shortest length and chamfer the line that intersects at that point to the outside offset line - badly explained I know, but working inwards should give you what you need.

 

 

One problem might be lines going left or right, but we can help you with that. I reckon all this is online somewere.... but we don't know your skill level... where do you need the help? and what have you done so far?

Link to comment
Share on other sites

1 hour ago, Keegan said:

i'm not programmer i'm just need help ... if anyone can program this lisp for me (paid service) please contact me message

thanks for all

 

That last sentence... someone will be interested.

 

 

 

-EDIT- Had a look online and the LISP to draw a line from a point to the nearest point was all there, copy and paste.... try this as a part way there (shoul be part way and useable to save some time) - command is ConnectBlocks

 

(just got to trim the connecting lines to the new wires, got to manually edit diagonal lines too just now)

 

 

;;https://www.cadtutor.net/forum/topic/21484-i-search-for-offset-with-same-value-and-opposite-direction/#comment-175406
(defun c:ConnectBlocks ( / acount MyLineSS MyBlockSS of MyOffSS)
;;Undo
  (defun *error* ( msg )
    (and undo (vla-EndUndomark doc))
    (or
      (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
      (princ (strcat "\n** Error: " msg " **"))
    )
    (princ)
  )

;;https://autocadtips1.com/2011/10/13/autolisp-perpendicular-to-entity/
;; by sinc @ the Swamp 07/22/2004
;; Repeatedly draws a line from a pick point perpendicular
;; to a selected object
  (defun perp2ent ( MyLine MyPoints / entity pt acount)
    (setq acount 0)
    (while (< acount (length MyPoints))
      (setq pt (nth acount MyPoints))
      (entmake (list '(0 . "LINE") (cons 10 (trans pt 1 0))
        (cons 11 (vlax-curve-getClosestPointTo MyLine (trans pt 1 0)))) ;_ list
      ) ;_ entmake
      (setq acount (+ acount 1))
    ) ;_ while
    (princ)
  ) ;_ defun

;; Loop layers selection
;;Select Route
  (princ "\nSelect Polyline Route ")
  (setq MyLineSS (ssget "_+.:E:S" (list (cons 0 "*LINE") ) ))

;;Get Offset
  (setq of 2.5) ; default offset, 2.5. Maybe work out as fraction of line length
;;  (setq of (getdist "\nSpecify Offset Distance: ")) ; User selects distance

;;Get blocks
;;Select Route
  (princ "\nSelect End Blocks ")
  (setq MyBlockSS (ssget (list (cons 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 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
      (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))
  )
  (perp2ent MyLine MyPoints)

;;Finish
;  (vla-EndUndoMark doc)
  (princ)
)

 

Edited by Steven P
Link to comment
Share on other sites

7 hours ago, Steven P said:

 

That last sentence... someone will be interested.

 

 

 

-EDIT- Had a look online and the LISP to draw a line from a point to the nearest point was all there, copy and paste.... try this as a part way there (shoul be part way and useable to save some time) - command is ConnectBlocks

 

(just got to trim the connecting lines to the new wires, got to manually edit diagonal lines too just now)

 

 

;;https://www.cadtutor.net/forum/topic/21484-i-search-for-offset-with-same-value-and-opposite-direction/#comment-175406
(defun c:ConnectBlocks ( / acount MyLineSS MyBlockSS of MyOffSS)
;;Undo
  (defun *error* ( msg )
    (and undo (vla-EndUndomark doc))
    (or
      (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
      (princ (strcat "\n** Error: " msg " **"))
    )
    (princ)
  )

;;https://autocadtips1.com/2011/10/13/autolisp-perpendicular-to-entity/
;; by sinc @ the Swamp 07/22/2004
;; Repeatedly draws a line from a pick point perpendicular
;; to a selected object
  (defun perp2ent ( MyLine MyPoints / entity pt acount)
    (setq acount 0)
    (while (< acount (length MyPoints))
      (setq pt (nth acount MyPoints))
      (entmake (list '(0 . "LINE") (cons 10 (trans pt 1 0))
        (cons 11 (vlax-curve-getClosestPointTo MyLine (trans pt 1 0)))) ;_ list
      ) ;_ entmake
      (setq acount (+ acount 1))
    ) ;_ while
    (princ)
  ) ;_ defun

;; Loop layers selection
;;Select Route
  (princ "\nSelect Polyline Route ")
  (setq MyLineSS (ssget "_+.:E:S" (list (cons 0 "*LINE") ) ))

;;Get Offset
  (setq of 2.5) ; default offset, 2.5. Maybe work out as fraction of line length
;;  (setq of (getdist "\nSpecify Offset Distance: ")) ; User selects distance

;;Get blocks
;;Select Route
  (princ "\nSelect End Blocks ")
  (setq MyBlockSS (ssget (list (cons 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 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
      (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))
  )
  (perp2ent MyLine MyPoints)

;;Finish
;  (vla-EndUndoMark doc)
  (princ)
)

 

thank you very much ... works well ... but please i want to edit as appear in my attached image ( 1st edit i want the route between main poly line and block with right angle  - 2nd i want lisp to flatten all polylines - 3rd i want the lisp to connect between each polyline from the block and the main route with fillet command to be the same as "sample DWG that i attached before") ... thank you very very very much

nnn.png

111.png

Link to comment
Share on other sites

5 hours ago, Keegan said:

thank you very much ... works well ... but please i want to edit as appear in my attached image ( 1st edit i want the route between main poly line and block with right angle  - 2nd i want lisp to flatten all polylines - 3rd i want the lisp to connect between each polyline from the block and the main route with fillet command to be the same as "sample DWG that i attached before") ... thank you very very very much

 

 

The bit I posted yesterday was the easy stuff - copy, modifying and pasting what I found online. Connecting the lines together and keeping things at right angles needs a little more thought.

 

For the right angles, and since we are talking about computer programming, there needs to be some rule for this that will fit all occasions otherwise there will often be a time where the LISP has got it 'wrong'. If it has drawn the lines at right angles this might not be so obvious - I might be tempted to suggest that the LISP can do 95% of the work and you'd have to manually adjust these last few lines that don't fit.

 

Link to comment
Share on other sites

I know you are wanting this ASAP and prepared to pay, just need to wait sometimes, another project I have just adding function each day and no charge. It will be finished soon paid even quicker.

 

It can be done have you Private Mailed BeekeecZ and Hak_Z their solutions were close. I don't want to take their code and hack it then charge you.

 

 

  • Like 1
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...