Jump to content

DC Chain lisp possibilities


Raz89

Recommended Posts

Hi all

 

Firstly I will start with my background so you all know where I am coming from for this question. I work for a company who do multiple water pipelines, channels and the like for mines, irrigation areas and the like. Most of these pipelines and channels require the addition of chainages along them for reference to structures and all that. At the moment we use a modified version of 'DC Chains', which I assume some of you are familiar with. Basically the major difference is that it adds our specified block for the chainage marker and a few other small differences.

 

At the moment the lisp requires us to input the chainage interval (or distance between chainage markers) and the initial or start chainage. The only problem with this is that we require the intervals to be at 100, 1000 or 10000m intervals for ease of viewing, but some of our pipelines start at odd chainages e.g. 1234m depending on what preceeds it etc.

 

The problem is that if you have an interval of 1000m and a starting chainage of 1234m then each subsequent chainage will be 2234, 3234 etc whereas we need them to be 2000, 3000.

 

My question is, is there a way to make the lisp start on a weird chainage, using example above, 1234m and then put the next chainage at the specified interval being 2000m but only 766m down the alignment then from there on continue with the initial spacings?

 

I was thinking that if I tried to re-write it with the input options of start chainage, first interval and normal interval I would be able to get it to place the second chainage at the required location and from there on out they will space at the required interval aswell. The only problem is that I do not know how to do this as of yet.

 

I am trying different things at the moment just to see but if anyone knows a way to do it, hints would be excellent so I can try it another way.

 

I will try and get a copy of the lisp and a jpeg of how it works at the moment and how I would like it to work ASAP but at the moment its being blocked by my IT department.

 

Thanks in advance.

Jarrod

Link to comment
Share on other sites

I will try and get a copy of the lisp and a jpeg of how it works at the moment and how I would like it to work ASAP but at the moment its being blocked by my IT department.

 

Below is the altered version of DC chains that we use. *Edit - Dammit, the spaces didn't all come out exactly as hoped.*

 

;draw chainages

;by Dave Corrall 12-Nov-2001 Revised 26.10.09

 

;degrees>radians

(defun dtr (a)

(* pi (/ a 180.0))

)

;radians>degrees

(defun rtd (a)

(* 180.0(/ a pi))

)

 

(defun intro ()

(setq dialog-state 999)

(setq dialog_pos (list -1 -1))

(setq dcl_id (load_dialog "intro.dcl"))

)

 

; tell about routine

 

(defun open_about ()

; (done_dialog)

(startapp "notepad.exe" "chains.txt")

; (setq userclick1 nil)

)

 

(defun quit_routine ()

(setq qr "Q")

)

 

 

(defun chainage20 ()

(setq oreq(getvar"attreq")odia(getvar"attdia"))

(setq oldlayer(getvar "clayer"))

(setvar "attreq" 1)

(setvar "attdia" 0)

(setvar "osmode" 1024)

(command "ucs" "")

(setq r 0.0)

(setq seg 0.0)

(if (= (tblsearch "LAYER" "C_ALIG_CHNG") nil)

(command "layer" "m" "C_ALIG_CHNG" "c" "7" "" "")

(command "layer" "s" "C_ALIG_CHNG" "")

)

(setq step(getreal "\nChainage interval: ")

svval(getreal "\nStart Chainage: ")

scale "1")

(setq nam (car (entsel "\nSelect Polyline: ")))

(setq ent (entget nam))

(if (not (equal (cdr (assoc 0 ent)) "LWPOLYLINE"))

(prompt "\nEntity not a polyline...")

(progn

(setq nv (cdr(assoc 90 ent)))

(setq ent1 (member(assoc 10 ent)ent))

(setq ent2(cdr ent1))

(setq ent2(member(assoc 10 ent2)ent2))

(while (/= ent2 nil)

(if (/= ent2 nil)

 

(progn

 

; IF THE VERTEX PRECEDES A STRAIGHT LINE

 

(if (equal (cdr (assoc 42 ent1)) 0.0)

(progn

(setq v1(cdr(assoc 10 ent1))

v2(cdr(assoc 10 ent2))

a(angle v1 v2)

d(distance v1 v2)

p1(polar v1 a (- step r))

d1(distance p1 v2)

)

(if(

(progn

(setq value(strcat (rtos svval 2 0)))

(command "-insert" "sv20" v1 scale scale (rtd a) value "")

)

)

(if(

(progn

(setq r (+ d r))

)

(progn

(setq num(1+(fix(/ d1 step))))

(setq cnt 0)

(repeat num

(progn

(setq pt(polar p1 a (* cnt step)))

(setq svval(+ svval step)

value(strcat (rtos svval 2 0)))

(command "-insert" "sv20" pt scale scale (rtd a) value "")

(setq cnt (1+ cnt))

)

)

(setq r(rem d1 step))

)

)

; set new values for variables

(setq ent1 ent2)

(setq ent2(cdr ent2))

(setq ent2(member(assoc 10 ent2)ent2))

(setq seg(1+ seg))

);end progn for straight section

;if the vertex preceds an arc

(progn

(setq v1(cdr(assoc 10 ent1))

v2(cdr(assoc 10 ent2))

bulge(cdr(assoc 42 ent1))

)

(setq a(angle v1 v2)

d(distance v1 v2)

radi(abs(/ d(* 2.0(sin(*(atan bulge) 2)))))

)

(setq hfd(/ d 2.0)

thet(atan(/(sqrt(-(* radi radi)(* hfd hfd)))hfd))

)

(if ( 180 deg

(if (

(setq dtoc (- a thet))

(setq dtoc (+ a thet))

)

(if (

(setq dtoc (+ a thet))

(setq dtoc (- a thet))

)

)

(setq p1 v1)

(setq p2 v2)

(setq pc (polar p1 dtoc radi))

(setq beg (angle pc p1))

(setq end (angle pc p2))

; CALCULATE LENGTH OF ARC

 

 

(setq swept (abs (- beg end) ))

(setq len (abs (* (- beg end) radi)))

(if (and ( swept pi ))

(setq len (- (* 2 pi radi) len))

)

 

 

(if (

(progn

(setq r (+ len r))

)

(progn

(if (and (> (abs bulge) 1) (

(setq len (- (* 2 pi radi) len))

)

(setq beta (- step r))

(setq len1 (- len beta))

(if (> bulge 0)

(setq beg (+ beg (/ beta radi) ) )

(setq beg (- beg (/ beta radi) ) )

)

(setq num (1+ (fix (/ len1 step))))

(setq astep (/ step radi ))

(setq cnt 0)

(repeat num

(progn

(if (> bulge 0)

(setq ai (+ beg (* cnt astep))

ab(+ ai (dtr 90)))

(setq ai (- beg (* cnt astep))

ab(- ai (dtr 90)))

)

(setq pt (polar pc ai radi))

(setq svval(+ svval step)

value(strcat (rtos svval 2 0)))

(command "-insert" "sv20" pt scale scale (rtd ab) value "")

(setq cnt (1+ cnt))

)

)

(setq r(rem len1 step))

(if(equal r 0.0)(setq r step))

)

)

; set new values for variables

(setq ent1 ent2)

(setq ent2(cdr ent2))

(setq ent2(member(assoc 10 ent2)ent2))

);end progn for arc section

);end if check straight or arc

);end progn

);end if /= ent2 nil

);end while /= ent2 nil

)

)

;reset variables

(setvar "attreq" oreq)

(setvar "attdia" odia)

(command "layer" "s" oldlayer "")

(command "ucs" "p")

)

(defun thanku()

(setq dialog-state 999)

(setq dialog_pos (list -1 -1))

(setq dcl_id (load_dialog "thanks.dcl"))

(while (

(new_dialog "thanks" dcl_id "" dialog_pos)

(set_tile "lname" "Chainage Routine")

(setq x (dimx_tile "DC")

y (dimy_tile "DC"))

(fill_image 0 0 x y -15)

(start_image "DC")

(slide_image 10 10 x y "dc_logo")

(end_image)

(setq dialog-state (start_dialog))

(if (= dialog-state 1)

(princ)

)

)

(unload_dialog dcl_id)

(princ)

)

 

;command routine

(defun c:chains20 ()

(intro)

(if(= qr "Q")

(progn

(setq qr nil)

(thanku)

)

(progn

(chainage20)

(thanku)

)

)

)

Link to comment
Share on other sites

I looked at code but I did not have time to wade through at point after svval(getreal "\nStart Chainage: ") you need to work out the next pt along based on the increment but minus the start value so 1234 would mean next point is 234 along not 1000 you would do once only maybe via an if the code works out the next point now so just needs a subtle change. No comments in code so time consumming to work which variable is next point

 

1234-1000 is not 0 odd= true
If odd is true
work new 2nd point and set odd true  
else odd is not true carry on as before

)

Link to comment
Share on other sites

^^ What he said, or SLW will get angry - You wouldn't like SLW when he's angry.

 

Words to live by right there. :thumbsup:

 

Please use CODE TAGS !

 

Thank You for reading this Public Service Announcement! :rtfm:

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