Author Topic: Elevating Flat Polylines to Close Numeric Text Value  (Read 10403 times)

0 Members and 1 Guest are viewing this topic.

jvillarreal

  • Bull Frog
  • Posts: 332
Elevating Flat Polylines to Close Numeric Text Value
« on: May 10, 2010, 07:19:38 AM »
Typically we will recieve contours in 3d from the surveyor or polylines containing object data which can be used to elevate them, but a few times the files will contain polylines with text calling out the elevations. After being asked to manually elevate these polylines, I put this together. Its been useful so far but is not worthy of the show your stuff category as it can definitely be enhanced. So to anybody interested, here it is.

;Routine will elevate flat segments by searching for numeric text objects within a starting and max radius.
;Text objects are skipped once max radius is reached.
;Currently only works with text objects
;used ssget->vla-list & list->variantArray functions written by CAB

*Edit*
Updated routine
« Last Edit: November 16, 2010, 12:09:57 PM by jvillarreal »

Pad

  • Bull Frog
  • Posts: 342
Re: Elevating flat polylines to close numeric text
« Reply #1 on: May 10, 2010, 10:22:19 AM »
cheers

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Elevating flat polylines to close numeric text
« Reply #2 on: November 16, 2010, 12:05:21 PM »
This routine has been a real time saver but was terrible with a large number of polyline segments so i've updated.
Am i missing any obvious ways to further cut run time?

Any advice is appreciated,
Juan

;Routine will elevate flat segments by selecting linework within a starting and max radius
;of the midpoint of text or mtext objects
;Text objects are skipped once max radius is reached.
;used ssget->vla-list by CAB

Code: [Select]
(defun ssget->vla-list (ss / i ename allobj)
 (if ss
  (progn
       (setq i -1)
       (while (setq  ename (ssname ss (setq i (1+ i))))
         (setq allobj (cons (vlax-ename->vla-object ename) allobj))
       )
       allobj
  )
 )
)

(defun c:autoelevate ( / linework number ent elist elevat circle *Space* newradius numlines
ActDoc bb pt1 pt2 insxpt midpoint radius increment count skipped maxrad inc)
(vl-load-com)
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq *Space* (vlax-get-property ActDoc (nth (vla-get-ActiveSpace ActDoc)'("PaperSpace" "ModelSpace"))))
(vla-EndUndoMark ActDoc)
(vla-StartUndoMark ActDoc)
(setq radius (getreal "\nEnter starting radius:"))
(while (or (null radius)(<= radius 0))(setq radius (getreal "\nEnter starting radius greater than 0:")))
(setq increment (getreal "\nEnter radius increment:"))
(while (or (null increment)(<= increment 0))(setq increment (getreal "\nEnter radius increment greater than 0:")))
(setq maxrad (getreal "\nEnter maximum radius:"))
(while (or (null maxrad)(< maxrad radius))(setq maxrad (getreal "\nEnter maximum (greater than radius):")))
(setq count 0 skipped 0)

(vlax-for i (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-Acad-Object)))
 (if (member (vla-get-objectname i) '("AcDbMText" "AcDbText"))
  (progn
   (vl-catch-all-apply 'vla-getboundingbox
    (list i
     'minpoint
     'maxpoint
    )
   )
   (setq pt1 (vlax-safearray->list minpoint)
         pt2 (vlax-safearray->list maxpoint)
         midpoint (mapcar '(lambda (a b) (/ (+ a b) 2.0)) pt1 pt2)
         inc (/ (* pi 2) 10)
         newradius radius
         elevat nil)

   (while (and (<= newradius maxrad)(null elevat))
    (setq plist nil n 0)
    (while (<= n 10)
           (setq n (1+ n)
                 plist (append plist (list (polar midpoint (* inc n) newradius)))
           )
    )
    (setq newradius (+ newradius increment))
    (and
     (setq linework
       (ssget->vla-list
         (ssget "_CP" plist (list (cons 0 "LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,ELLIPSE")))))
     (setq number (vla-get-textstring i)
           elevat (atoi number)
     )
     (eq (vla-get-elevation (nth 0 linework)) 0.0)
     (not (vla-put-elevation (nth 0 linework) elevat))
     (setq count (1+ count))
     (grtext -2 (strcat (itoa count) " Flat Segments Elevated."))
    );and
   );while
  );progn
 );if
);vlax-for

(vla-EndUndoMark ActDoc)
(princ (strcat "\nProcess Complete..." (itoa count) " Flat Segments Elevated."))
(princ)
);defun autoelevate
(defun c:aev ()(c:autoelevate))
« Last Edit: November 16, 2010, 12:42:04 PM by jvillarreal »

Robert98

  • Guest
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #3 on: November 16, 2010, 12:49:21 PM »
Hi Jvillarreal
I have a question about autoelevate routine . dose it work with block points or no ? namely , the texts are related to some point blocks , please ,  if possible for you put a gif animated hint for use of this routine . I'm a beginner and still in learning stage , and don't deal whit vlisp codes ! :-o
thanks

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #4 on: November 16, 2010, 02:35:26 PM »
Sorry for the late response..was at the company thanksgiving lunch...
This routine doesn't work with block points but can be modified to work with anything as long as you can extract an elevation from the object.

You could change this section to get the block.

Code: [Select]
(vlax-for i (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-Acad-Object)))
 (if [color=red](member (vla-get-objectname i) '("AcDbMText" "AcDbText"))[/color]

and this section to extract the textstring from the block
Code: [Select]
   (and
     (setq linework
       (ssget->vla-list
         (ssget "_CP" plist (list (cons 0 "LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,ELLIPSE")))))
     (setq number [color=red](vla-get-textstring i)[/color]
           elevat (atoi number)
     )
     (eq (vla-get-elevation (nth 0 linework)) 0.0)
     (not (vla-put-elevation (nth 0 linework) elevat))
     (setq count (1+ count))
     (grtext -2 (strcat (itoa count) " Flat Segments Elevated."))
    );and

A gif wouldn't do much good for this routine..
You have to provide a starting radius, increment to increase radius, and maxradius.
In this case, for each (m)text object found, a selection is attempted using the user input radius. If no linework is selected, the radius is increased and the process is repeated until the user input max radius is reached or linework is selected.  
« Last Edit: November 16, 2010, 02:49:55 PM by jvillarreal »

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #5 on: November 16, 2010, 02:46:30 PM »
from the outside it appears you are creating elevated polylines by using 'proximity' information, sounds like a very bad practice if one is creating terrain models.  One would be far ahead of the curve to use real survey data such as the point(s) blocks being referred to instead of proximal elevation information from text entries.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #6 on: November 16, 2010, 02:53:24 PM »
from the outside it appears you are creating elevated polylines by using 'proximity' information, sounds like a very bad practice if one is creating terrain models.  One would be far ahead of the curve to use real survey data such as the point(s) blocks being referred to instead of proximal elevation information from text entries.

This routine is intended to do as you described. I ONLY use this routine when no other survey information is available as described in the first post.
(At times, we will receive polylines with elevation provided in text form only. This routine removes the slow/mundane task of manually elevating each polyline.)
« Last Edit: November 16, 2010, 02:57:43 PM by jvillarreal »

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #7 on: November 16, 2010, 03:03:44 PM »
from the outside it appears you are creating elevated polylines by using 'proximity' information, sounds like a very bad practice if one is creating terrain models.  One would be far ahead of the curve to use real survey data such as the point(s) blocks being referred to instead of proximal elevation information from text entries.

This routine is intended to do as you described. I ONLY use this routine when no other survey information is available as described in the first post.
(At times, we will receive polylines with elevation provided in text form only. This routine removes the slow/mundane task of manually elevating each polyline.)
do you have MAP?  it's possible to extract those text entities to points through a Query to Report function; I use this method often when converting Ariel Topography to TINS.  perhpas this is a process you might try as well
Be your Best


Michael Farrell
http://primeservicesglobal.com/

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #8 on: November 16, 2010, 03:09:26 PM »
Quote
do you have MAP?  it's possible to extract those text entities to points through a Query to Report function; I use this method often when converting Ariel Topography to TINS.  perhpas this is a process you might try as well

I do have map and am not familiar with the Query to Report function. The position of the text provided is not always on the linework provided. How will extracting the text entities to points be any more accurate?

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #9 on: November 16, 2010, 03:19:06 PM »
Quote
do you have MAP?  it's possible to extract those text entities to points through a Query to Report function; I use this method often when converting Ariel Topography to TINS.  perhpas this is a process you might try as well

I do have map and am not familiar with the Query to Report function. The position of the text provided is not always on the linework provided. How will extracting the text entities to points be any more accurate?

given that there are sufficient points, one can construct the original surface from them.
Process for map query report:
Attach the source file to a NEW MAP drawing
Query in the Text, either by object or layer
Change Query Type From Preview To Report
Extrat the X and y of the text objects AND the TVALUE of the Text
Execute the query

It then writes and XYZ file that you then import as a point file...
build your surface from thata data

In the case of Ariel Topo I generally work with the SPOT X's and the text adjacent to them
If you look at your data closely  there might be similar Spot X's to work from as well
Also consider asking the source for the  LandXML file of that surface and save everyone the grief.

*small rant here* You will need to open the report and SAVE AS to CSV from excel because autodesk broke this report file generator about 4 years ago, and it adds phantom  'HEX' data to the TXT file created even though it should be a simple asci text file
Be your Best


Michael Farrell
http://primeservicesglobal.com/

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #10 on: November 16, 2010, 03:27:56 PM »
Thanks for the lesson Michael. I will definitely use that process in the future. Unfortunately there are no spot x's to work with in some cases and the elevation is not always called out sufficiently enough to use the text as points. The most recent time i had to use this routine was due to financial issues. The surveyor was asking for more money to provide any information in 3d.  :x
Nice to know there are other options though. Thanks again!
« Last Edit: November 16, 2010, 04:19:35 PM by jvillarreal »

Robert98

  • Guest
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #11 on: November 21, 2010, 03:24:31 PM »
Sorry for the late response..was at the company thanksgiving lunch...
This routine doesn't work with block points but can be modified to work with anything as long as you can extract an elevation from the object.

You could change this section to get the block.

Code: [Select]
(vlax-for i (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-Acad-Object)))
 (if [color=red](member (vla-get-objectname i) '("AcDbMText" "AcDbText"))[/color]

and this section to extract the textstring from the block
Code: [Select]
   (and
     (setq linework
       (ssget->vla-list
         (ssget "_CP" plist (list (cons 0 "LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,ELLIPSE")))))
     (setq number [color=red](vla-get-textstring i)[/color]
           elevat (atoi number)
     )
     (eq (vla-get-elevation (nth 0 linework)) 0.0)
     (not (vla-put-elevation (nth 0 linework) elevat))
     (setq count (1+ count))
     (grtext -2 (strcat (itoa count) " Flat Segments Elevated."))
    );and

A gif wouldn't do much good for this routine..
You have to provide a starting radius, increment to increase radius, and maxradius.
In this case, for each (m)text object found, a selection is attempted using the user input radius. If no linework is selected, the radius is increased and the process is repeated until the user input max radius is reached or linework is selected.  


Thanks Jvillarreal for response , and now I'm sorry for the late ! it is my favorite when I work with old version of topographic maps .  :wink:
« Last Edit: November 21, 2010, 03:29:05 PM by Robert98 »

huiz

  • Swamp Rat
  • Posts: 913
  • Certified Prof C3D
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #12 on: November 22, 2010, 03:45:22 AM »
...
Nice to know there are other options though. Thanks again!

In Civil3D there is a command for doing that, and you don't have to use queries and textfiles.

Also here http://www.theswamp.org/index.php?topic=31812.msg373120#msg373120  you can find information to create 3D points from texts, using VB.Net. At home I also have a compiled version of that so if you're interested in that tool, I'll mail it.

But your routine is very interesting for creating breaklines, though in Civil3D there is an option to use proximity breaklines which will do the same, as long as there are 3D points above the nodes.

The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #13 on: November 22, 2010, 04:50:59 PM »
Glad you like it Robert.

Huiz,

What is the command in Civil 3d? I'm definitely interested in your tool and would be thankful if you shared it. Thanks, Juan

huiz

  • Swamp Rat
  • Posts: 913
  • Certified Prof C3D
Re: Elevating Flat Polylines to Close Numeric Text Value
« Reply #14 on: November 23, 2010, 02:08:59 AM »
The command is AeccMoveTextToElevation.

If I'm home, I'll try to upload the tool.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.