Author Topic: Offset Existing Surface Profile  (Read 19033 times)

0 Members and 1 Guest are viewing this topic.

enderprime

  • Guest
Re: Offset Existing Surface Profile
« Reply #15 on: November 22, 2012, 04:16:33 PM »
Unfortunately I wrote it at work so I can't post the code directly I can only point in the right direction.. which is a real shame it's one of the cooler things I've done with CAD.
The basic process for creating a polyline out of a dynamic profile:

  • Get selection of a profile and a profile view from user, convert using (vlax-ename->vla-object)
  • (getreal) offset distance from user, which could be 0 for a direct trace, and if not 0 also (getpoint) for offset side from user
  • Use vlax-get-property and vlax-invoke-method to drill down a few levels into the profile until you find station-elevation properties of sub-entities
  • Use vlax-get-property to get profile view properties such as start station, start elevation, bounding box, and vertical scale
  • Combine data above into formulas that convert station-elevation pairs into a list of (x,y) coordinates
  • Use the calculated (x,y) coordinate list to create a polyline (command .. , entmake, whatever you prefer)
  • Issue native autocad offset command on (entlast)

If we just want an offset polyline then we're done at this point. But my boss also wanted an option to create a new profile instead, so then:
  • Compile a vertex list from the new polyline (dxf group code = 10), and converted these (x, y) back into station-elevation
  • Use (open) and (write-line) to create a local text file
  • Issue the civil 3D command (CreateProfileFromFile)

The hard part is getting to the profile sub-entities, since there is really no documentation on using LISP to interact with civil 3D objects. The Autodesk forums won't even acknowledge your intent unless you are using .net now.. However, you can use (vlax-dump-object) to get all the properties and methods you can access for any object type. From there it's a little bit of blind coding.

enderprime

  • Guest
Re: Offset Existing Surface Profile
« Reply #16 on: August 14, 2013, 02:06:21 PM »