Author Topic: Civil 3D Inquiry Tool & Labels  (Read 20901 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Civil 3D Inquiry Tool & Labels
« Reply #15 on: July 31, 2012, 02:54:11 PM »

For the line though; do you just handle the deletion in the Catch/Finally block (if it exists)?  :? If so, then I'd need to define the new 'line' outside of my Try scope, correct (otherwise the Catch/Finally block couldn't see it)?

Thanks!
First, be sure to use a LWPolyline, not a line. Lines report different parameters than plines/pipes. And just be sure to Dim the temppoly as nothing prior to the Try...block. I don't actually do it this way since my code operates on the entire network, whichever pipe/structure is closest to the cursor gets acted on. I create a collection of polylines for each pipe in the network at command startup that I dispose of as the command ends.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Inquiry Tool & Labels
« Reply #16 on: August 07, 2012, 10:00:56 AM »
Hey Jeff,

I was helping another member here with using the GetPoints Method for a Feature Line, and saw the GetGradesAtPoint Method.

... Do you think it would be faster (programmatically speaking) to query a simple Feature Line (start & end points) using the GetGradesAtPoint Method, rather than a LWPolyline and have to calculate the elevation?  :?

Also, vlax-dump-object shows that the GetGradesAtPoint Method has three arguments, but I cannot seem to find this Method in Object Browser (with both AecBaseMgd, and AeccDbMgd referenced)... Where can I find more on this?
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Civil 3D Inquiry Tool & Labels
« Reply #17 on: August 07, 2012, 10:26:49 AM »

... Do you think it would be faster (programmatically speaking) to query a simple Feature Line (start & end points) using the GetGradesAtPoint Method, rather than a LWPolyline and have to calculate the elevation?  :? Adding the overhead of a Featureline may be counterproductive. All i can say is try it if you want :-)

Also, vlax-dump-object shows that the GetGradesAtPoint Method has three arguments, but I cannot seem to find this Method in Object Browser (with both AecBaseMgd, and AeccDbMgd referenced)... Where can I find more on this? This is a COM object, so look in Autodesk.Aecc.Interop.Land

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D Inquiry Tool & Labels
« Reply #18 on: August 07, 2012, 10:29:25 AM »
I don't know, what I don't know... Awesome, thanks!
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Civil 3D Inquiry Tool & Labels
« Reply #19 on: September 06, 2014, 02:30:54 PM »
Came across this thread while writing a program similar to Jeff's. I got everything to working, but I am curious, how do you deal with arced pipes? I will say that I was writing this for storm/sewer pipes, and I've never used the arc pipe option (that I can recall :uglystupid2: ), so this is purely academic.

Either way, thank you for the nudge in the right direction for normal elevation inquiry.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Civil 3D Inquiry Tool & Labels
« Reply #20 on: September 06, 2014, 02:53:22 PM »
Alan, are you using lisp or .NET? In my .NET app I actually calc/create arced plines for the curved pipes as well. Here's a snip from the method where I add the Curve/Pipe pair to a Dictionary:
Code - C#: [Select]
  1.         private void getPipes(PipesDB.Network ntwrk)
  2.         {
  3.             curves.Clear();
  4.             foreach (ObjectId id in ntwrk.GetPipeIds())
  5.             {
  6.                 PipesDB.Pipe pipe = (PipesDB.Pipe)id.GetObject(OpenMode.ForRead);
  7.                 ///must convert Pipe object to temporary Curve object, Pipe does not support the GetClosestPointTo method we need to use
  8.                 Curve crv = null;
  9.  
  10.                 if (pipe.SubEntityType == PipesDB.PipeSubEntityType.Straight)
  11.                 {
  12.                     Line line = new Line(pipe.StartPoint.FlattenedPoint(), pipe.EndPoint.FlattenedPoint());
  13.                     crv = (Curve)line;
  14.                 }
  15.                 else //it's a curved pipe
  16.                 {
  17.                     Point2d mid = pipe.GetPointAtParam(0.5).Convert2d(GeometryUtil.PlaneXY);
  18.                     Point2d startpt = pipe.StartPoint.Convert2d(GeometryUtil.PlaneXY);
  19.                     Point2d endpt = pipe.EndPoint.Convert2d(GeometryUtil.PlaneXY);
  20.                     Point2d midcrd = new Point2d((startpt.X + endpt.X) * 0.5, (startpt.Y + endpt.Y) * 0.5);
  21.                     Vector2d vec2d = mid.GetVectorTo(midcrd);
  22.                     Point2d radPt = Polar(mid, vec2d.Angle, pipe.Radius);
  23.                     double angIn = radPt.GetVectorTo(startpt).Angle;
  24.                     double angOut = radPt.GetVectorTo(endpt).Angle;
  25.                     Arc arc = new Arc(new Point3d(radPt.X, radPt.Y, 0), pipe.Radius, angIn, angOut);
  26.                     Point2d arcmid = arc.GetPointAtParameterQuux((arc.StartParam + arc.EndParam) * 0.5).Convert2d(GeometryUtil.PlaneXY);
  27.  
  28.                     crv = arc;
  29.                     if (!(arcmid.GetDistanceTo(mid) < 0.1))
  30.                     {
  31.                         arc.StartAngle = angOut;
  32.                         arc.EndAngle = angIn;
  33.                         Polyline pline = new Polyline();
  34.                         pline.AddVertexAt(0, startpt, -arc.GetArcBulge(), 0, 0);
  35.                         pline.AddVertexAt(1, endpt, 0, 0, 0);
  36.                         crv = pline;
  37.                     }
  38.                 }
  39.                 curves.Add(crv, pipe);
  40.             }
  41.         }
  42.  
  43.  
Yes, there are a number of helper/extension methods used, but it should give you the sense of what it's doing.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Civil 3D Inquiry Tool & Labels
« Reply #21 on: April 23, 2015, 06:14:11 AM »
Hello!
I wondering the same problem and donīt get it solved.
1) A LspCode here calculates start- & and-point from pipe. The x/y coordinates are right but the z-coordinate is constant 0.2 to hight.

2) When I get I want interpolate a point to the pickpoint on pipe, which way is best. Calculation or work with Polylines and get closed-point

Code: [Select]
(defun c:xx()
  (while (null (setq vEnt (entsel ))))
    (setq vEnt (vlax-ename->vla-object (car vEnt)))
    (if (= (vla-get-ObjectName vEnt ) "AeccDbPipe")
      (progn
(setq p1 (vlax-safearray->list (vlax-variant-value (vlax-get-property vEnt 'PointAtParam 0))))
(setq p2 (vlax-safearray->list (vlax-variant-value (vlax-get-property vEnt 'PointAtParam 1))))

(princ (strcat "\nElevation in Picked point: \n" (strcat "Start: " (vl-princ-to-string p1) "- End: " (vl-princ-to-string p2))))
(princ)
        )
      )
  )

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Civil 3D Inquiry Tool & Labels
« Reply #22 on: April 23, 2015, 10:25:53 AM »
The values retrieved for a pipe are at the center of the pipe.To get the inverts you must use the InnerHeight of the pipe, divide by 2, subtract that from the desired point. Insert this into your code for that....
Code - Auto/Visual Lisp: [Select]
  1.         (setq halfsize (* 0.5 (vlax-get-property vEnt 'InnerHeight)))
  2.         (setq p1 (list (car p1) (cadr p1) (- (last p1) halfsize)))
  3.         (setq p2 (list (car p2) (cadr p2) (- (last p2) halfsize)))
  4.  

Personally, I would work with lines/arcs to get the interpolated points.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D Inquiry Tool & Labels
« Reply #23 on: April 23, 2015, 10:59:34 AM »
The values retrieved for a pipe are at the center of the pipe.To get the inverts you must use the InnerHeight of the pipe, divide by 2, subtract that from the desired point. Insert this into your code for that....
Code - Auto/Visual Lisp: [Select]
  1.         (setq halfsize (* 0.5 (vlax-get-property vEnt 'InnerHeight)))
  2.         (setq p1 (list (car p1) (cadr p1) (- (last p1) halfsize)))
  3.         (setq p2 (list (car p2) (cadr p2) (- (last p2) halfsize)))
  4.  

Personally, I would work with lines/arcs to get the interpolated points.

yes, but would not drawing all those lines and or arcs, sort of defeat the purpose of using 3d pipes at all?   
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Civil 3D Inquiry Tool & Labels
« Reply #24 on: April 23, 2015, 11:34:42 AM »
yes, but would not drawing all those lines and or arcs, sort of defeat the purpose of using 3d pipes at all?   
Not at all, Michael. When trying to customize C3D with lisp, one must sometimes jump through hoops to get the desired results. This is just one of those cases where using simple, temporary, linework, based on the 3d pipes, allows one to get the desired data. It is not readily available from the Pipe object itself.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Civil 3D Inquiry Tool & Labels
« Reply #25 on: April 23, 2015, 12:26:18 PM »
Great thanx Jeff! I get idea too but I was not sure. Your picture in thread looks nice.
But you solved that with .NET or?

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Civil 3D Inquiry Tool & Labels
« Reply #26 on: April 23, 2015, 12:36:26 PM »
Yes, I coded my solution in C# and the .NET API

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D Inquiry Tool & Labels
« Reply #27 on: April 23, 2015, 12:44:04 PM »
yes, but would not drawing all those lines and or arcs, sort of defeat the purpose of using 3d pipes at all?   
Not at all, Michael. When trying to customize C3D with lisp, one must sometimes jump through hoops to get the desired results. This is just one of those cases where using simple, temporary, linework, based on the 3d pipes, allows one to get the desired data. It is not readily available from the Pipe object itself.

I would count that among the many fails lurking inside C3D.....and yet it's full steam ahead trying to shoehorn MORE functions into Infraworks   :idiot2:
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Civil 3D Inquiry Tool & Labels
« Reply #28 on: April 23, 2015, 01:52:05 PM »
Nothing 'fail' about this. They have said from the start "do not expect to be able to customize C3D in lisp, not everything is, or will be, exposed for use in lisp". Those who choose to try to do so are basically doing so at their own risk. I gave up trying to force it to work in lisp 7+ years ago. I still can't do EVERYTHING I'd like to do with the API's provided, but I'm pleased that I'm at least able to do a LOT of what I want. Unlike some other civil packages out there.

And, fwiw, C3D development is still alive and kicking.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D Inquiry Tool & Labels
« Reply #29 on: April 23, 2015, 02:11:43 PM »

And, fwiw, C3D development is still alive and kicking.

Yes, I know however they appear to be ignoring issues with existing features/functions.
For example; long standing issues with pipes and labels and that damnable 'part builder'.
Be your Best


Michael Farrell
http://primeservicesglobal.com/