Jump to content

Recommended Posts

Posted

I am looking for a lisp that can help draw pipe and insert blocks and trim the pipe to the blocks. See attached picture for Reference.

 

This is what I am look for in a lisp:

 

1. Load lisp and run it.

2. Command line prompted for: Pipe,Pipe Down,Pipe Up,Hose Bib,Value

 

Example: Drawing pipe item 4 below and pipe down comes up you do pipe down and the block 5 is inserted and trims the item and draws pipe again.

 

I hope this give a good Idea what i am try to do. I am try to get the command prompt to come up after every command and only exits if esc is hit.

 

Thanks in advance for everything!!!

PL.JPG

Posted

Another way to add description in every block def

Inside parenthesise are distances at right and at left

from insertion point

See pic :)

 

~'J'~

hint.JPG

Posted

I have not written the lisp but rather the sequence

 

Setq ans to say P for pipe first

then while ans /= nil

cond P run defun pipe

D run defun down

U run defun up etc

lastly please enter choice p d u etc if you press enter this equals a nil hence while exits

 

Hope this helps it won't trim the blocks but will repeat prompt

 

I am sure if you know your block characteristics size in each direction then you can work out the trim problem you need to save these for each block in the lisp or alternatively I would have a text file that you could change if you change your blocks. block1 L R U D

Posted

Ok I am going to set up what I have so far. From then only one change, but i think this can help others.

Posted

I used this lisp that was stated above and changed a few things. I can figure out how to get it to use the same point at theses lines.

 

(setq ip (getpoint "\nInsertion Point: "))

;get the insertion point

(setq ent1 (entsel "\nSelect Line to AutoBreak: "))

;get the line to break

 

I am trying to get the insertion point in the line to be the same as the the line, that is so I have have to click twice only click the insertion point on the line and the the block is there and trimmed.

 

(defun c:abreak ( / oldsnap ip ent1 ent2 ep1 ep2 ang edata ip1 ip2)

(setq oldsnap (getvar "OSMODE"))

;get the current snap

(setvar "OSMODE" 544)

;set snap to intersection and nearest

(setvar "BLIPMODE" 0)

;switch blips off

(setvar "CMDECHO" 0)

;switch command echo off

(while

;while an insertion point is selected

(setq ip (getpoint "\nInsertion Point: "))

;get the insertion point

(setq ent1 (entsel "\nSelect Line to AutoBreak: "))

;get the line to break

(setvar "OSMODE" 0)

;switch the snap off

(setq ent2 (entget (car ent1)))

;get the entity data of the line

(setq ep1 (cdr (assoc 10 ent2)))

;get the first end point

(setq ep2 (cdr (assoc 11 ent2)))

;get the second end point

(setq ang (angle ep1 ep2))

;get the angle of the line

(setq ang (/ (* ang 180.0) pi))

;convert it to degrees

(setvar "ATTDIA" 0)

;switch off the attribute dialog box

(command "Insert" "valve1" ip "" "" ang "" "")

;insert the block

(setq edata (entget (setq en (entlast))))

;get the block entity data

(setq edata (entget (entnext (dxf -1 edata))))

;get the attribute entity list

(setq ip1 (dxf 10 edata))

;extract the first attribute insertion point

(setq edata (entget (entnext (dxf -1 edata))))

;get the next attribute entity list

(setq ip2 (dxf 10 edata))

;extract the second attribute insertion point

(command "Break" ent1 "f" ip1 ip2)

;break the line

(setvar "OSMODE" 544)

;switch snap back on

);while

(setvar "OSMODE" oldsnap)

;reset snap

(setvar "BLIPMODE" 1)

;switch blips back on

(setvar "CMDECHO" 1)

;switch command echo back on

(setvar "ATTDIA" 1)

;switch attribute dialog boc back on

(princ)

;finish clean

);defun

;;;**********************************************************

 

(defun dxf (code elist)

(cdr (assoc code elist))

);defun

(princ)

Posted

Sorry, I may be mis-understanding you - are you trying to get it so that you only have to click for the insertion point of the block and it automatically recogises the line that its on?

Posted

This will make it a single click, see how you get on with it:

 

(setq ent1 (entsel "\nSelect Point for Block...")
     ip   (osnap (cadr ent1) "_nea"))

Posted

Yes I want to click for the insertion point of the block and it automatically recogises he line that its on. Is the code you send going to replace this code stated below???

 

(setq ip (getpoint "\nInsertion Point: "))

(setq ent1 (entsel "\nSelect Line to AutoBreak: "))

Posted

Yes, just substitute it for that,

 

the return of "entsel" is the entity name and the point that was clicked, so I am merely snapping the point to the nearest line.

Posted
This will make it a single click, see how you get on with it:

 

(setq ent1 (entsel "\nSelect Point for Block...")
     ip   (osnap (cadr ent1) "_nea")

 

Is the ip at the beginning of the second line spose to be in ()? It looks weird to me.

Posted

Oops! sorry, missed a parenthesis!

 

(setq ent1 (entsel "\nSelect Point for Block...")
     ip   (osnap (cadr ent1) "_nea"))

Posted
Is the ip at the beginning of the second line spose to be in ()? It looks weird to me.

 

That would be a variable ("IP" is the name of a variable).

 

It already is enclosed with in paren's. SETQ can accept multiple arguments [as in (setq var1 value1 var2 value2 ...)] and the AutoLisp interpreter ignores white space so what is typed out for you already:

 

(setq ent1 (entsel "\nSelect Point for Block...")

ip (osnap (cadr ent1) "_nea"))

 

looks basically just like this to the interpreter:

 

(setq ent1 (entsel "\nSelect Point for Block...") ip (osnap (cadr ent1) "_nea"))

Posted
That would be a variable ("IP" is the name of a variable).

 

It already is enclosed with in paren's. SETQ can accept multiple arguments [as in (setq var1 value1 var2 value2 ...)] and the AutoLisp interpreter ignores white space so what is typed out for you already:

 

(setq ent1 (entsel "\nSelect Point for Block...")

ip (osnap (cadr ent1) "_nea"))

 

looks basically just like this to the interpreter:

 

(setq ent1 (entsel "\nSelect Point for Block...") ip (osnap (cadr ent1) "_nea"))

 

Thanks!! I noticed after looking at it, that it was not two lines, but one line.

Posted

I like to list it as two lines most of the time, so that you can pick the variables from the values they are being set to - otherwise its not always clear.

Posted

Bit more as two lines its what your used to when writing lisp

(setq ent1 (entsel "\nSelect Point for Block..."))

(setq ip (osnap (cadr ent1) "_nea"))

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