Jump to content

Offset a line without input from user(prompting)


avinashg

Recommended Posts

Hi All,

I am new to this forum and lisp.

Trying to create cross sections of drain using lisp.The details of are fed from excel for each cross section.I am stuck as I was not able to figure out the way to offset line/polyline by selecting the lines and offset distance from the program itself.

Any help would be appreciated.

 

Thanks in advance.:)

 

Cross SectionOf EWE H-100ch 0 to 575m.dwg

read_excel_data_to_array.lsp

drain.xls

 

I have grabbed the code given by Fixo to read data from excel (http://www.cadtutor.net/forum/showthread.php?41910-Read-Excel-Data-Cells-and-Draw-in-AutoCAD-thru-LISP/page2). Thanks Fixo.

Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • avinashg

    13

  • Tharwat

    6

  • Dadgad

    2

  • neophoible

    2

Top Posters In This Topic

In order to start a lisp you need to enter the shortcall for the lisp, which will likely be at least two letters, that is assuming that it is already loaded.

In order to start the OFFSET command you enter the letter O.

How many key strokes are you hoping to save?

Link to comment
Share on other sites

In order to start a lisp you need to enter the shortcall for the lisp, which will likely be at least two letters, that is assuming that it is already loaded.

In order to start the OFFSET command you enter the letter O.

How many key strokes are you hoping to save?

 

Dadgad,

What do u mean by strokes.(Sorry I am a newbee in lisp)

I have already created polyline using lisps i need to offset the same polyline using same program.

Link to comment
Share on other sites

I have already created polyline using lisps i need to offset the same polyline using same program.

 

Check this out , and you can change the minus to plus to play with the two sides :)

 

(defun c:Test (/ d side s i)
 (vl-load-com)
 (setq d 1.0)
 (if (setq s (ssget "_:L" '((0 . "LINE"))))
   (repeat (setq i (sslength s))
     (vla-offset (vlax-ename->vla-object (ssname s (setq i (1- i)))) (- d))
     )
   )
 (princ)
 ) 

Link to comment
Share on other sites

Was the original post deleted?

Am not sure something might have happened anyhow m re posting it.

 

Hi all,

I am trying to create cross sections of drain using lisp data fed from excel.(Used the code posted by fixo in some thread) and drawing polylines and lines.

I am struck as I am not able to figure out how to offset a line/polyline without prompting for selecting line and offset distance.

Here are the files

 

 

If anyone (with little free time) can help me by creating the program will be very gratefull.

drain.xls

read_excel_data_to_array.lsp

Cross SectionOf EWE H-100ch 0 to 575m.dwg

Link to comment
Share on other sites

Welcome to the forum. :)

Your first post was not a post, just the thread title, with no additional information. :wink:

Now I understand that you are looking to add an OFFSET command into an existing lisp.

Sorry I am lisp-challenged myself, but it doesn't sound too difficult, Iam sure

somebody will straighten you out.

 

By key strokes, I mean each time you enter a character on your keyboard.

Link to comment
Share on other sites

Check this out , and you can change the minus to plus to play with the two sides :)

 

(defun c:Test (/ d side s i)
 (vl-load-com)
 (setq d 1.0)
 (if (setq s (ssget "_:L" '((0 . "LINE"))))
   (repeat (setq i (sslength s))
     (vla-offset (vlax-ename->vla-object (ssname s (setq i (1- i)))) (- d))
     )
   )
 (princ)
 ) 

 

 

Tharwat,

This program even though creates offset will prompt to select line.

 

(ssget "_:L" '((0 . "LINE")))

Link to comment
Share on other sites

Tharwat,

This program even though creates offset will prompt to select line.

 

(ssget "_:L" '((0 . "LINE")))

 

Yes , according to what you have mentioned in the title of the thread .

 

* Does it mean that you want to offset all Polylines one time ?

* How long is the distance ?

Link to comment
Share on other sites

Is there any way I can offset a line without prompting to select line.

Like select line in the background by referring to its points :(

Link to comment
Share on other sites

Is there any way I can offset a line without prompting to select line.

Like select line in the background by referring to its points :(

Yes , replace this ..

 

(ssget "_:L" '((0 . "LINE")))

 

with this .. ( but unlock all layers that might any line lay on )

 

(ssget "_x" '((0 . "LINE")))

Link to comment
Share on other sites

Yes , according to what you have mentioned in the title of the thread .

 

* Does it mean that you want to offset all Polylines one time ?

* How long is the distance ?

 

Yes offset all polylines at once or selected polylines at once.

A polygon created using polyline.

 

Distance is around 5

 

Please have a look at this.

Cross SectionOf EWE H-100ch 0 to 575m.dwg

Link to comment
Share on other sites

Yes , replace this ..

 

(ssget "_:L" '((0 . "LINE")))

with this .. ( but unlock all layers that might any line lay on )

 

(ssget "_x" '((0 . "LINE")))

 

 

Tharwat,

I am getting the prompt for selecting objects even after replacing as you said :(.Along with this error.

 

 Error: bad argument type: lentityp <Selection set: 85> 

Link to comment
Share on other sites

Like this .

 

(defun c:Test (/ d side s i)   
(vl-load-com)  
(setq d 1.0) [b][color=red];;; <= change the distance to meet your needs[/color][/b]  
(if (setq s (ssget "_[b]x[/b]" '((0 . "[color=red][b]LINE[/b][/color]")))) [b][color=red];;; <= change entity type to Polyline if you want[/color][/b]    
(repeat (setq i (sslength s))   
   (vla-offset (vlax-ename->vla-object (ssname s (setq i (1- i))))
([b][color=red]-[/color][/b] d)) [b][color=red];; <= change from minus to plus if you want the opposite side[/color][/b]     
 )     ) 
 (princ)   )

Link to comment
Share on other sites

Thanks a lot Tharwat :D it offsets all lines in the drawing.

 

You're welcome anytime :)

 

 

 

Is there any way I can select lines within a specific region.:unsure:

 

Which region do you mean ? Model , and Layouts ???

Link to comment
Share on other sites

I need to select two line in the model and offset those two.

Just guessing whether it can be done specifying rectangular region(as in when selecting in gui) or by specifying the points of lines

Hope it makes sense.

Link to comment
Share on other sites

I need to select two line in the model and offset those two.

Just guessing whether it can be done specifying rectangular region(as in when selecting in gui) or by specifying the points of lines

Hope it makes sense.

 

If you mean rectangular selection set , you can go back to my first routine and it would help you with it , otherwise more details needed :lol:

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...