Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA Project object to profile view

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
mgof
1092 Views, 6 Replies

VBA Project object to profile view

I am trying to automatically project all objects on an alignement to all the profile views corresponding to an alignment (would save a lot of time to have it for drawings where I have dozens of PV).

 

From what I have found so far, the only option to project objects to profile view from VBA code is through a SendCommand.

 

Other options could work, like:

StationOffset to retrieve the blocks metric poin, then FindXYAtStationAndElevation and finally insert a new block at these coordinates. This option is not valid for me as it creates actually new blocks and will not allow to dynamically update the exact location of the blocks on the profile view. In other words, the objects on the PV must be "AECC_PROFILE_PROJECTION", not "INSERT".

 

I decided to go for the following option (since the _AECCPROJECTOBJECTSTOPROF command does not have a VBA equivalent - why btw?):

Select all the blocks and then use the following:

 

ThisDrawing.SendCommand "_AECCPROJECTOBJECTSTOPROF" & vbCr & "Previous" & vbCr & vbCr & PVXmax(i) & "," & PVYmax(i) & vbCr

 

where

  1. "Previous" refers to the last selection sets which corresponds to all blocks close to an alignment
  2. PVXmax(i) and PVYmax(i) are the coordinates of the insertion point of the PV (got these after selecting all Profile Views in the drawing from objent.GetBoundingBox VarMin, VarMax - here it is VarMin).

Doing this, I still need to select manually the profile view (although it sends the correct coordinates to AutoCAD). Any idea why?

6 REPLIES 6
Message 2 of 7
mgof
in reply to: mgof

Did not get any reaction on this... Anything wrong in my post?

Message 3 of 7
Jeff_M
in reply to: mgof

@mgof, no, nothing wrong with your description in the post. However, finding anyone who still uses VBA for C3D will be difficult. I haven't even installed VBA since C3D2010. As for using SendCommand with that command, sending the correct coordinates for the PV location may not be finding the PV due to those coordinates not actually falling on an object in the PV. 

 

And regarding this: "(since the _AECCPROJECTOBJECTSTOPROF command does not have a VBA equivalent - why btw?):", Autodesk has said for years that they had stopped adding anything to the COM API for C3D, all new features would be .NET only. SO that would be my first guess as to why.

Jeff_M, also a frequent Swamper
EESignature
Message 4 of 7
Jeff_M
in reply to: Jeff_M

However, I'm not seeing a method in .NET to ProjectObjectsToProfile. Not something I've had a need to try...
Jeff_M, also a frequent Swamper
EESignature
Message 5 of 7
mgof
in reply to: Jeff_M

@Jeff_M Thanks for the reply.

I am rather new to C3D (started with 2015). I used to handle VBA codes namely from Excel files and that's why I tried to do this from VBA. I deal with exports and imports from Excel and all the existing coding is in VBA...

 

From what I understand, I'd better simply shift to .NET instead of VBA. I will definitely do that. If you have any idea on where to start from on this (doc/tuto)...

 

 

Regarding the SendCommand and the points coordinates on the PV, they seem fall on the lower left corner of the PV. It might be a problem of accuracy.

Message 6 of 7
Jeff_M
in reply to: mgof

@mgof, to get started with .NET and Autocad in general ADN (Autodesk Developer Network) has the "My first Autocad Plug-in" tutorial on THIS page. There are also some sample apps for C3D using VB.NET, including the Pipes Example which interacts with Excel, located here: C:\Program Files\Autodesk\AutoCAD 2015\C3D\Sample\Civil 3D API\DotNet\VB.NET

 

However, I will say that I found that dropping VB and going with C# made the transition to .NET better for me. That way I didn't try to keep doing things the same as I did in VBA (VBA & VB.NET are similar, but quite different at the same time). Plus, there are far more examples available for c#. It was, and still is, a learning process but I am so glad I made that decision back then.

 

On the other hand, all of the source code provided with C3D for the .NET reports, Subassemblies, and Rules are all done in VB. SO if yu ever need/want to edit those you will need to have at least a basic understanding of how to use VB.NET.

Jeff_M, also a frequent Swamper
EESignature
Message 7 of 7
mgof
in reply to: Jeff_M

Just found one way to make the selection by point work: first zoom on the object you want to select.

In this case, something like:

Set PVObj = ThisDrawing.HandleToObject(PVHandle(i))

PVObj.GetBoundingBox Varmin, VarMax
ZoomWindow Varmin, VarMax
ThisDrawing.SendCommand "_AECCPROJECTOBJECTSTOPROF" & vbCr & "Previous" & vbCr & vbCr & Varmin(0) & "," & VarMax(1) & vbCr

 

Though I finalized this in VBA, I am getting started with VB.net. Thanks @Jeff_M

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report