Author Topic: Trimm extend between civil3D objects  (Read 1755 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Trimm extend between civil3D objects
« on: September 27, 2013, 02:21:22 AM »
Hello!

I have a question to my problem with civil3d objects. I want create a closed Polyline between terrass- and ground-sectioObject. That means I have done a sectionview in Civil3d that haves 2 objects (look picture "before"). Object 1 have this properties:
Quote
((-1 . <Entity name: 7ffff861530>) (0 . "AECC_SECTION") (330 . <Entity name: 7ffff8139f0>) (5 . "11565B") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "SEKTION") (100 . "AeccDbEntity") (100 . "AeccDbGeo_aec") (100 . "AeccDbGeo") (100 . "AeccDbSection"))

If I list entity 330 I see that is a block
((-1 . <Entity name: 7ffff8139f0>) (0 . "BLOCK_RECORD") (5 . "1F") (102 . "{ACAD_XDICTIONARY") (360 . <Entity name: 7ffff81ff70>) (102 . "}") (330 . <Entity name: 7ffff813810>) (100 . "AcDbSymbolTableRecord") (100 . "AcDbBlockTableRecord") (2 . "*Model_Space") (360 . <Entity name: 7ffff813a00>) (340 . <Entity name: 7ffff813a20>) (70 . 0) (280 . 1) (281 . 0))

I have no idea how I can find in VLA correctly object.

In the end I want create a closed Polyline looks like pict. "after"

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Trimm extend between civil3D objects
« Reply #1 on: September 27, 2013, 11:32:50 AM »
Using the ActiveX objects... (setq obj (vlax-ename->vla-object (car (entsel)))) ... this gives you an AeccSection object which has a Links property from which you can gather the points to create a polyline with. However, in my testing I have found that the Datum section returns some invalid points outside the daylight points. I've posted about this on the Autodesk C3D customization forum: HERE . Here's the lisp I used to get to that point, perhaps it will help you with completing the chore.

Code - Auto/Visual Lisp: [Select]
  1. ;;select vla-object
  2. (defun vl-sel (/ ent)
  3.   (if (setq ent (car (entsel "\nSelect object: ")))
  4.     (vlax-ename->vla-object ent)
  5.     )
  6.   )
  7.  
  8. ;;convert a C3D section object to a list of points from which a polyline
  9. ;; may be created
  10. (defun getpointlist (sctn / links idx link start end ptlist)
  11.   (setq links (vlax-get-property sctn 'links))
  12.   (setq idx -1)
  13.   (while (< (setq idx (1+ idx)) (vlax-get links 'count))
  14.     (setq link  (vlax-invoke links 'item idx)
  15.           start (cons (vlax-get link 'startpointx) (vlax-get link 'startpointy))
  16.           end   (cons (vlax-get link 'endpointx) (vlax-get link 'endpointy))
  17.     )
  18.     (if (not (member start ptlist))
  19.       (setq ptlist (cons start ptlist))
  20.     )
  21.     (if (not (member end ptlist))
  22.       (setq ptlist (cons end ptlist))
  23.     )
  24.   )
  25.   (setq ptlist (reverse ptlist))
  26. )
  27.  
  28.  
  29. ;;select the ground section, then the datum section
  30. (setq grnd (vl-sel)
  31.       dtm  (vl-sel)
  32. )
  33. ;;get the points
  34. (setq grndpts (getpointlist grnd)
  35.       datumpts (getpointlist dtm)
  36.       )
  37.  

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Trimm extend between civil3D objects
« Reply #2 on: September 27, 2013, 03:26:26 PM »
Here's a more complete version that correctly draws a polyline. Remember, if you want the areas you will need to compensate for any vertical exaggeration.

I leave it up to you to make it work continuously and/or automatically.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:drawpolyonsection (/ datumpts doc dtm grnd grndpts mspace pline prunedpts sctnvw)
  2.  
  3.   ;;select vla-object
  4.   (defun vl-sel (msg / ent)
  5.     (if (setq ent (car (entsel msg)))
  6.       (vlax-ename->vla-object ent)
  7.     )
  8.   )
  9.  
  10.   ;;convert a C3D section object to a list of points from which a polyline
  11.   ;; may be created
  12.   (defun getpointlist
  13.          (sctn sctnvw / links idx link start end ptlist x y)
  14.     (setq links (vlax-get-property sctn 'links))
  15.     (setq idx -1)
  16.     (while (< (setq idx (1+ idx)) (vlax-get links 'count))
  17.       (setq link (vlax-invoke links 'item idx))
  18.         sctnvw
  19.         'FindXYAtStationOffsetAndElevation
  20.         0
  21.         (vlax-get link 'startpointx)
  22.         (vlax-get link 'startpointy)
  23.         'x
  24.         'y
  25.       )
  26.       (setq start (cons x y))
  27.         sctnvw
  28.         'FindXYAtStationOffsetAndElevation
  29.         0
  30.         (vlax-get link 'endpointx)
  31.         (vlax-get link 'endpointy)
  32.         'x
  33.         'y
  34.       )
  35.       (setq end (cons x y)
  36.       )
  37.       (if (= (vlax-get link 'type) 0)
  38.         ;;this link is displayed
  39.         (progn
  40.           (if (not (member start ptlist))
  41.             (setq ptlist (cons start ptlist))
  42.           )
  43.           (if (not (member end ptlist))
  44.             (setq ptlist (cons end ptlist))
  45.           )
  46.         )
  47.       )
  48.     )
  49.     (setq ptlist (reverse ptlist))
  50.   )
  51.  
  52.   (defun flattenlist (lst / result)
  53.     (foreach l lst
  54.       (setq result (cons (car l) result)
  55.             result (cons (cdr l) result)
  56.       )
  57.     )
  58.     result
  59.   )
  60.  
  61.  
  62.   ;;selct the ground section, then the datum section, then the sectionview
  63.   (setq grnd   (vl-sel "\nSelect ground section: ")
  64.         dtm    (vl-sel "\nSelect datum section: ")
  65.         sctnvw (vl-sel "\nSelect SectionView: ")
  66.   )
  67.   ;;get the points, all start from left and go to the right
  68.   (setq grndpts  (getpointlist grnd sctnvw)
  69.         datumpts (getpointlist dtm sctnvw)
  70.   )
  71.  
  72.  
  73.   ;;use the points to construct pline. Omit the ground points outside the limits of the datum
  74.   (setq prunedpts nil)
  75.   (foreach pt grndpts
  76.     (if (and (> (car pt) (caar datumpts))
  77.              (< (car pt) (car (last datumpts)))
  78.         )
  79.       (setq prunedpts (cons pt prunedpts))
  80.     )
  81.   )
  82.         mspace (vla-get-modelspace doc)
  83.   )
  84.   (setq pline (vlax-invoke
  85.                 mspace
  86.                 'addlightweightpolyline
  87.                 (reverse (flattenlist (append datumpts prunedpts)))
  88.               )
  89.   )
  90.   (vla-put-closed pline :vlax-true)
  91.   (princ)
  92. )
  93.  

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Trimm extend between civil3D objects
« Reply #3 on: September 30, 2013, 07:20:53 AM »
Thatīs very nice done - thank you for your work Jeff.