TheSwamp

CAD Forums => Vertically Challenged => Land Lubber / Geographically Positioned => Topic started by: Guest on October 10, 2006, 03:40:54 PM

Title: Assigning contour elevations...
Post by: Guest on October 10, 2006, 03:40:54 PM
...to 5,170 contours.  What's the easiest way??

Yeah, I've got a drawing with over 5,000 contours (currently plines) that I need to make "real".  I'm using LDT5.  I'm hoping I don't have to click on each one to set the elevation.

Maybe someone has a little program they'd like to share??

I'm open to any/all ideas.
Title: Re: Assigning contour elevations...
Post by: Jeff_M on October 10, 2006, 03:57:04 PM
Well, I'd rather talk to you here than the other place, so.....

How do you know what the elevation is supposed to be for the plines?
Title: Re: Assigning contour elevations...
Post by: Guest on October 10, 2006, 04:05:48 PM
There's a piece of text sitting on every 10 foot contour.
Title: Re: Assigning contour elevations...
Post by: Jeff_M on October 10, 2006, 04:27:19 PM
Sorry, Matt, I don't have anything already coded. About the best I can come up with right now would be to set one of the lowest plines at it's elevation, then have a program that would have you select the plines by a Fence and it would assign elevations upwardly in 1' (or whatever they should be) increments. Trouble is, I'm not so sure a Fence would actually select in order so you'd probaly have to sort them based on interection point vs start point. May be a tall order......good luck! If I get some time I'll see what I can do about the actual code.
Title: Re: Assigning contour elevations...
Post by: Swift on October 10, 2006, 05:15:19 PM
Hey guys I worked on something like what he needs a while back for when I digitized contours but I never finished it. I was working on the ideal of a crossing line and using the distance from first end point to intersections to determine the contour elevations.
Title: Re: Assigning contour elevations...
Post by: T.Willey on October 10, 2006, 05:24:37 PM
If the text is on the pline, then would an ssget for text, with the fence, where the fence points are the pline points, grab the text?  If so then you know the elevation for that pline, and are able to change the elevation.

Just thinking out loud.  I'm not a civil guy, so if I'm way off base, just let me know.
Title: Re: Assigning contour elevations...
Post by: Dinosaur on October 10, 2006, 05:40:57 PM
In case there are no automated solutions offered that work for you, here is how I would progress along the  l  o  n  g  route.
I would start this project with a MAP cleanup operation (you have LDT5 so I know you have MAP) to eliminate any gaps or overlaps in the segments you need to join.  This will also do most of the joining for you if you chose the right settings.
Are these things all have the same layer or color and linetype?  If they are different in one or more property, you can use the select similar command to break the index contours out and change just those to a layer you can isolate.  This will break the task visually into easier chunks.  The easiest approach if they are not to any elevation already (I am assuming that you have checked and found no Z values) is to start joining the segments into a continuous ployline and change the polylines to a different layer as you finish with them and assign the correct elevation.  It will take a while but it is not prohibitive as long as you have done the cleanup first.
Title: Re: Assigning contour elevations...
Post by: LE on October 10, 2006, 05:53:53 PM
Can you upload a sample drawing (just a small area)... if you can.
Title: Re: Assigning contour elevations...
Post by: sinc on October 10, 2006, 05:56:42 PM
...to 5,170 contours.  What's the easiest way??

Yeah, I've got a drawing with over 5,000 contours (currently plines) that I need to make "real".  I'm using LDT5.  I'm hoping I don't have to click on each one to set the elevation.


How are you currently doing this task?  Are you clicking on each line and typing the elevation in the Properties?

There's also the "Assign Elevation" command in the Contour Utilities.  It's easier than typing every elevation, but I still wouldn't want to use it for 5000+ contours...

I don't suppose there's any chance you can go back to whoever created the contours and have them give you something more useful, like a TIN?  That would definitely be "the easiest way"...   :-D
Title: Re: Assigning contour elevations...
Post by: SomeCallMeDave on October 10, 2006, 06:16:09 PM
Here is a quick routine that may help.  Swift's post gave me the idea for it.

It assumes that the contour entities are LWPolylines, and that the color of them has been change to something other than ByLayer. And also that the linetype doesn't have any dashes.  Sometimes fence misses a pick due to dashes.

Draw a pline from downhill to uphill, that crosses each contour only once.  The routine can't do the whole site at once, but it should be faster than picking them manually.

I haven't tested it much, but maybe it will help.

Code: [Select]
(defun c:SetELev()
   (setq Ent1 (car (entsel "\nSelect Fence Pline "))
         LowestEl (getreal "\nEnter Lowest Elevation ")
         ContInter (getreal "\nEnter Contour Interval ")
         LastVert (fix (vlax-curve-getEndParam Ent1))
         VertList (list (vlax-curve-getPointAtParam Ent1 0))
         count 1
         oEnt1 (vlax-ename->vla-object Ent1)
   )     
   
   (repeat LastVert   
      (setq VertList (append VertList (list (vlax-curve-GetPointAtParam Ent1 Count)))
            Count (+ Count 1)   
      )     
   
    )
   
    (setq ss1 (ssget "F" VertList)
          Count 0
          CrossPtList nil
          ss1 (ssdel Ent1 ss1)
    );setq
   
       
    (repeat (sslength ss1)
       (if  CrossPtList
           (setq CrossPtList (append CrossPtList (list (last (last (last (ssnamex ss1 count) )))) ) )
           (setq CrossPtList (list (last (last (last (ssnamex ss1 count))))))
       );if
       (setq Count (+ count 1))
    );repeat
   
    (setq DistList nil
          Count 0
          CurrElev LowestEl
         
    );setq
   
    (repeat (length CrossPtList)
       (if DistList
           (setq DistList (append DistList (list (vlax-curve-GetDistAtPoint Ent1 (vlax-curve-getClosestPointTo Ent1 (nth count CrossPtList))))))
           (setq DistList (list (vlax-curve-GetDistAtPoint Ent1 (vlax-curve-getClosestPointTo Ent1 (nth count CrossPtList)))))
       );if
       (setq count (+ 1 count))         
    );repeat
    (setq DistListSortI (vl-sort-i DistList '<)
          count 0
    );setq
   
    (repeat (length DistListSortI)
       (setq currEnt (ssname ss1 (nth count DistListSortI))
             currElev (+ LowestEl (* ContInter count))
             CurrEntList (entget currEnt)
             ;change the elevation
             CurrEntList (subst (cons 38 currElev) (assoc 38 CurrEntList) CurrEntList)
             ;change the color so we can keep track
             colorIndex 6
             CurrEntList (subst (cons 62 colorIndex) (assoc 62 CurrEntList) CurrEntList)
        );setq
        (entmod CurrEntList)
        (setq count (+ count 1))
    )

)

Title: Re: Assigning contour elevations...
Post by: LE on October 10, 2006, 06:26:59 PM
Something I would do in lisp is:

If the text objects are on top of each polyline and the polyline is not broken in that part, then... do:

1. Select the text entities.
2. Iterate over each text and get the bounding box.
3. Make a selection from those two points using ssget "c" and use a filter for a polyline.
4. Make sure the selection is equal to one (0) item, an use the string value of the text, assign it to the polyline and call ssdel to delete the item (pline) from the selection.

I think that might work.
Title: Re: Assigning contour elevations...
Post by: LE on October 10, 2006, 06:57:04 PM
And here is.... you can run more tests and make it better.

Good luck!

Code: [Select]
(defun C:TEST  (/ ss p1 p2 s pline txt)
  (if (setq ss (ssget '((0 . "TEXT"))))
    (progn
      (mapcar
'(lambda (obj)
   (vla-getboundingbox obj 'p1 'p2)
   (setq p1 (vlax-safearray->list p1))
   (setq p2 (vlax-safearray->list p2))
   (if (setq s (ssget "_C" p1 p2 '((0 . "LWPOLYLINE"))))
     (progn
       (setq pline (vlax-ename->vla-object (ssname s 0)))
       (setq txt (vla-get-textstring obj))
       (vla-put-elevation pline (distof txt)))))
(mapcar 'vlax-ename->vla-object
(vl-remove-if
  (function listp)
  (mapcar (function cadr) (ssnamex ss))))))))
(princ)
Title: Re: Assigning contour elevations...
Post by: MMccall on October 10, 2006, 07:14:03 PM
I ran a quick web search and came up with a company named 4D Technologies that has a collection of GeoTools (over 200 tools).  Two of the tools are made just for the purpose of assigning elevations to contour lines.  $149 to buy, might have a free demo period to test it out.  You can alsos purchase them one tool at a time. ($2-8 each)
Title: Re: Assigning contour elevations...
Post by: LE on October 10, 2006, 07:21:59 PM
Hey!!!

I write commands for a custom Civil CAD application - and I/We here normally give the code for free....  :-)
Title: Re: Assigning contour elevations...
Post by: MMccall on October 10, 2006, 07:31:13 PM
I meant no disrespect to those that have the ability to write their own stuff and I do appreciate you freely sharing it with everyone.   I only meant it as a quick, cheap, and simple alternative to those, like myself , that look at the code you've shared and still don't really know what to do with it.  :ugly:
Title: Re: Assigning contour elevations...
Post by: LE on October 10, 2006, 07:41:54 PM
No problem Sir.


Here is the command again, with just minor changes... still can be improved a lot!

Code: [Select]
(defun C:ASSIGNELEV  (/ ss p1 p2 s pline txt)
  (prompt "\nSelect text elevation items...")
  (if (setq ss (ssget '((0 . "TEXT"))))
    (progn
      (mapcar
'(lambda (obj)
   (vla-getboundingbox obj 'p1 'p2)
   (setq p1 (vlax-safearray->list p1))
   (setq p2 (vlax-safearray->list p2))
   (if (setq s (ssget "_C" p1 p2 '((0 . "LWPOLYLINE"))))
     (progn
       (setq pline (vlax-ename->vla-object (ssname s 0)))
       (setq txt (vla-get-textstring obj))
       (if
(and (numberp (distof txt))
      (/= (distof txt) 0))
  (progn
    (vla-put-elevation pline (distof txt)))))))
(mapcar 'vlax-ename->vla-object
(vl-remove-if
  (function listp)
  (mapcar (function cadr) (ssnamex ss)))))))
  (princ))
(princ)
Title: Re: Assigning contour elevations...
Post by: MP on October 10, 2006, 07:43:39 PM
I meant no disrespect to those that have the ability to write their own stuff and I do appreciate you freely sharing it with everyone.   I only meant it as a quick, cheap, and simple alternative to those, like myself , that look at the code you've shared and still don't really know what to do with it.  :ugly:

Personally I think there's a place for both kinds of solutions as long as all is done according to the swamp's guidelines. Most folks that frequent here are looking for different fishing techniques, and thank goodness for veteran fisher persons like Luis. On the other hand, sometimes ones time is pressing and instant fish just might be the answer.

:)
Title: Re: Assigning contour elevations...
Post by: Dinosaur on October 10, 2006, 07:45:44 PM
. . . What's the easiest way?? . . . Maybe someone has a little program they'd like to share??

I'm open to any/all ideas.

And a reasonable suggestion it was, MMcall.  The initial question did not preclude a purchase nor did it specify a lisp or any other type routine.

I don't understand programming myself and thus find myself learning some of the native AutoCAD solutions such as my suggestion to try MAP.  With only a few minutes of setting the options and perhaps running it through 2 or 3 times, the cleanup would reduce the number of objects needing to be addressed to a very manageable number - and it is already on his computer.
Title: Re: Assigning contour elevations...
Post by: LE on October 10, 2006, 10:28:37 PM
Personally I think there's a place for both kinds of solutions as long as all is done according to the swamp's guidelines. Most folks that frequent here are looking for different fishing techniques, and thank goodness for veteran fisher persons like Luis. On the other hand, sometimes ones time is pressing and instant fish just might be the answer.

:)


 :-)

Glad if I can help....
Good for others (if they get benefit) right now.... And lately, that I do not have any other thing to do.... once I get back into a normal life (having a job) I will focus in a real life stuff....

For now.... please Have Fun!
Title: Re: Assigning contour elevations...
Post by: MP on October 10, 2006, 10:42:30 PM
What the ... I'm seeing double??

Glad if I can help....
Good for others (if they get benefit) right now.... And lately, that I do not have any other thing to do.... once I get back into a normal life (having a job) I will focus in a real life stuff....

For now.... please Have Fun!

Glad if I can help....
Good for others right now.... and lately that I do not any other thing to do.... once I get back into a normal life (having a job) I will focus in other stuff....

For now.... please Have Fun!

Note to self: See doctor about the sleeping pills I've been taking lately.
Title: Re: Assigning contour elevations...
Post by: LE on October 10, 2006, 10:53:52 PM
Yikes..... man, I need glasses too....  :-P

it is something wrong with thesamp setup he he - blame it yeah!
Title: Re: Assigning contour elevations...
Post by: FengK on October 11, 2006, 01:47:57 AM
I think the code provided by LE should do the work.  If the lwpolylines are broken by the text objects, I guess you can scale all the text by an appropriate factor using the boundingbox center as base point for scaling so that the boundingbox will touch the two lwpolylines on each side of the text object.  Afterwards when using LE's code, each selection should return two lwpolylines which will be assigned with the elevation extracted from the text object. Finally, scale those text objects down to their original size.
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 08:32:07 AM
Quote
Here is a quick routine that may help.  Swift's post gave me the idea for it.

It assumes that the contour entities are LWPolylines, and that the color of them has been change to something other than ByLayer. And also that the linetype doesn't have any dashes.  Sometimes fence misses a pick due to dashes.

Draw a pline from downhill to uphill, that crosses each contour only once.  The routine can't do the whole site at once, but it should be faster than picking them manually.

I haven't tested it much, but maybe it will help.

Some may call you Dave, but right now, I'm gonna call you a HUGE TIME SAVER!!

From what I've seen so far, it appears to be working like a charm!


I didn't use Map to clean up the drawing (mainly because I'm not familiar with Map - AT ALL!!).  Instead, I used a handly little gem I found by Jürg Menzi called AutoJoin which will join multiple lines, arcs and plines into one (or more) plines.  Sweet little tool.  Using that I decreased the original number or "contour" lines from about 29,000 down to the 5,000+ plines that I now have.

Thanks to all for your suggestions and input!!

Now all I have to do is study SomeCallMeDave's code to find out exactly what it's doing (I don't know much of anything about vlisp).  Maybe someone with more brains than I could enlighten me as to how the code knows which order to pick the lines to change them?!?

Thanks again everyone!
Title: Re: Assigning contour elevations...
Post by: Greg B on October 11, 2006, 08:53:50 AM
Wow!

You guys are amazing!
Title: Re: Assigning contour elevations...
Post by: SomeCallMeDave on October 11, 2006, 09:10:05 AM
Matt,

I'm glad you found the code helpful.

The routine creates a selection set by fence, using the pline you draw as the source of the fence coordinates.

Then it creates list of the intersections of the fence pline and each contour that it crossed. (using ssnamex)

Then it creates a list of distances (measured from the start of the fence pline to each intersection point).

It sorts these distances,  then picks the contour from the selection set based on this sorting, assigns it the lowest elevation, then picks the next contour, assigns  lowest elevation + 1*contour interval,  etc.

The list 'DistListSortI'  holds indexes of the sorted distances.  Using that index, the code
reaches into the selection set and gets the correct contour.

Does that explaination makes sense?
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 09:16:16 AM
Oh, it's more than helpful..... it's saving me a TON of time (time that I can use to surf the 'net)  :-)

Yeah, the explanation makes sense.  Now I just have to make sense of the code itself.

Thanks again.
Title: Re: Assigning contour elevations...
Post by: Maverick® on October 11, 2006, 09:24:58 AM
Hey Matt.  Just for S&G.  How much time do you think it saved over what you probably would have ended up doing had the Swamp not been here?  I think it would be a nice eye opener for peeps who don't really customize or have bosses who don't think the time to learn such things is justified.  Or for companies that don't think people should be hanging around the Swamp during work hours.

  I don't use Acad so I have no clue.  Like I said, just curious.  Just yesterday I had some .dwgs I needed to import into the cad software  I use.  The .dwgs as sent didn't import at all.  I sent them to another Swamper who knows Acad and he cleaned them up and made it so I could import them.  Probably a total of 5-10 minutes time.  That very possibly saved me 1.5 hours of phone calls, having the person who sent them figure out the problem, and waiting for them to resend.  Money in the bank.
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 10:00:44 AM
Quote
How much time do you think it saved over what you probably would have ended up doing had the Swamp not been here?

I would have to guesstimate 6-8 hours is how long it would have taken me to do it the "Land Desktop" way (which is picking a line, typing in the elevation, wash, rinse, repeat 5,169 more times!).

I'm going to say (after all is said and done) this will have taken me about an hour.  The program can't do ALL of the contours.  Take for instance these little green contours floating all by themselves.  I have no idea if they're up or down so for those I'm just going to do them the LDT way.

(http://img245.imageshack.us/img245/6467/setelevdz7.png)

So, to sum up... I'm going to say that I'll have saved about 6-7 hours.  So now I can organize my MP3 collection, dust off the plants (maybe even water them), clean out the keyboard - You ever do that and notice how many eyelashes come flying out of there??!  Kinda gross.  If you've never done it before, now's the time - flip that bad boy over and give it a couple of whacks  :pissed: and see what comes out.   :-o

Ummm... on that note, I think I've probably killed this thread.
Title: Re: Assigning contour elevations...
Post by: Greg B on October 11, 2006, 10:15:05 AM
  I don't use Acad so I have no clue.  Like I said, just curious.  Just yesterday I had some .dwgs I needed to import into the cad software  I use.  The .dwgs as sent didn't import at all.  I sent them to another Swamper who knows Acad and he cleaned them up and made it so I could import them.  Probably a total of 5-10 minutes time.  That very possibly saved me 1.5 hours of phone calls, having the person who sent them figure out the problem, and waiting for them to resend.  Money in the bank.

You are welcome sir!
Title: Re: Assigning contour elevations...
Post by: LE on October 11, 2006, 10:16:59 AM
If it is possible (and if you still have the previous drawing), I would like to use it as a sample test of an ObjectARX command, I want to do just as an exercise (of course take all the proprietary data first)

Thanks.
Title: Re: Assigning contour elevations...
Post by: Maverick® on October 11, 2006, 10:19:07 AM

You are welcome sir!

The check is in the mail.   :wink:
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 10:40:01 AM
Here's a portion of the site (my original zip file of contours was over 11MB).  I stripped out everything but the contour plines.  Their Z elevation is set to 0.

Have fun with it!

And upon further review, I need to change my estimated time of completion to about 2+/- hours.  There are more of those little contours just floating out there than I had originally thought.  So if I had to do this the LDT way, it would easily take me about 10 hours to assign the contour elevations.

*edit* removed attachment
Title: Re: Assigning contour elevations...
Post by: LE on October 11, 2006, 10:44:26 AM
And upon further review, I need to change my estimated time of completion to about 2+/- hours.  There are more of those little contours just floating out there than I had originally thought.  So if I had to do this the LDT way, it would easily take me about 10 hours to assign the contour elevations.

For some reason, is returning an Error every time, I tried to download the Zip....
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 11:01:46 AM
Quote
For some reason, is returning an Error every time, I tried to download the Zip....

Well then, here's the DWG file.
Title: Re: Assigning contour elevations...
Post by: LE on October 11, 2006, 11:02:55 AM
It does the same... no way to download it....
Title: Re: Assigning contour elevations...
Post by: PHX cadie on October 11, 2006, 11:03:07 AM
For some reason, is returning an Error every time, I tried to download the Zip....

x2
I'm dying of curiosity, tho its been downloaded 7 times before  ? ? ?

IE:
The server returned an invalid or unrecognized response
Title: Re: Assigning contour elevations...
Post by: LE on October 11, 2006, 11:07:37 AM
I think is now a task for the Moderators.... to find out what's going on.... I'll check later.

Thanks.
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 11:10:03 AM
I just tried both files and got this...

Quote
While trying to retrieve the URL: http://www.theswamp.org/index.php?

The following error was encountered:

Zero Sized Reply
Squid did not receive any data for this request.

Your cache administrator is webmaster.

--------------------------------------------------------------------------------

Generated Wed, 11 Oct 2006 15:09:36 GMT by gorb.bvhis.com (squid/2.5.STABLE9)


Not sure if it's because of restrictions in place on my side or not...
Title: Re: Assigning contour elevations...
Post by: MP on October 11, 2006, 11:12:45 AM
Damn calamari errors anyway.
Title: Re: Assigning contour elevations...
Post by: Greg B on October 11, 2006, 11:34:02 AM
Drawing size limit?  Never really uploaded?
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 11:40:49 AM
I"M DONE!!!   :-)

Now all I have to do is convert the plines to contour objects, label them and kick back, and drink some beers!!  Well, maybe a virtual beer.
Title: Re: Assigning contour elevations...
Post by: PHX cadie on October 11, 2006, 11:47:33 AM
...................... and drink some beers!!  ........................

Now that I can help with!

Still wanna see the problem child

<remenissing about the good ole days, doing a topo of "Town of Mammoth", not Mammoth, CA...sigh..... :cry:>
Title: Re: Assigning contour elevations...
Post by: Guest on October 11, 2006, 11:52:15 AM
Okay.... now onto the NEXT problem: Trimming the contours within the building limits.  Anyone got any easy way to trim multiple objects within multiple closed plines?
Title: Re: Assigning contour elevations...
Post by: Dinosaur on October 11, 2006, 12:11:36 PM
I think is now a task for the Moderators.... to find out what's going on.... I'll check later.

Thanks.
I had a similar problem earlier this week with another big drawing file I tried to download . . . the number cranked up one or two notches each time I tried, but never got a download.  I finally had to get it by email.  I think a size limit is in effect that must be the problem.  Sounds like a Mark question to me.
Title: Re: Assigning contour elevations...
Post by: LE on October 11, 2006, 12:29:44 PM
Thanks Dino;

At least I tried...  :-)

Still will write the command... and once I have it something, I'll post back.


Have fun.
Title: Re: Assigning contour elevations...
Post by: Guest on October 12, 2006, 08:32:49 AM
Has the download issue been resolved?  I noticed Mark removed my original ZIP file. Was there something wrong with it?  Was it corrupted??

Just curious.
Title: Re: Assigning contour elevations...
Post by: Mark on October 12, 2006, 08:37:40 AM
Has the download issue been resolved?  I noticed Mark removed my original ZIP file. Was there something wrong with it?  Was it corrupted??

I looked at it Matt but couldn't figure it out. I removed the first one in hopes that there was some type of conflict.
Title: Re: Assigning contour elevations...
Post by: Dinosaur on October 12, 2006, 08:41:11 AM
It still won't download.  Like I mentioned, I had the same problem getting a file Drizzt had posted that was about 6mb.
Title: Re: Assigning contour elevations...
Post by: Mark on October 12, 2006, 09:11:03 AM
You can always try putting the file here ==> http://www.theswamp.org/screens/
Title: Re: Assigning contour elevations...
Post by: FengK on October 12, 2006, 01:38:36 PM
A suggestion, maybe Swamp can apply for another gmail account for all members, just for exchanging files.
Title: Re: Assigning contour elevations...
Post by: Mark on October 12, 2006, 03:20:46 PM
A suggestion, maybe Swamp can apply for another gmail account for all members, just for exchanging files.

not a bad idea!