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: 

Read XML Files via Macro

10 REPLIES 10
Reply
Message 1 of 11
ramd401
436 Views, 10 Replies

Read XML Files via Macro

Hi, iam trying to write a macro in vba that can shiw me a msg about a select segment label for parcel (Eg. L1)

As soon as i activate the macro, it asks me to select a label segment and it gives me the following information

* Segmente name (L1)

* Start easting

* start northing

* azimuth

*segment lengh

*end easting

*end northing

10 REPLIES 10
Message 2 of 11
augusto.goncalves
in reply to: ramd401

Hi,

 

I'm not sure how familiar you are with VBA programming and macros.

 

The Parcel Segment object contains the name and a list of segments elements, which contains the geometry information:

 

http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccParcelSegment.htm

http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccParcelSegmentElem...

 

Do you have anything already?

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 3 of 11
ramd401
in reply to: augusto.goncalves

Hi, Augusto, iam not so familiar with macros, iam going to start going deep in near future, so for this time i just would like a macro code to use in a userform iam buildind that can give me the msgs i have mentioned

When i click the command botton it has to ask me to select the label segment (general line label stile) as soon as i select i can see can be in a textbox the messages of the informations i have mentioned before.

 

 

Just to clarify, i atached an image, the iformation i have in the table is the one i want to appear in the msg or even in a textbox

 

Remember that iam not so familiar with macros, iam starting reading the reference guides you have mentioned

 

 

Rosario Dilo (Regards)

 

 

 

 

Message 4 of 11
ramd401
in reply to: augusto.goncalves

Hi August I could write the macro like this, so the problem is that i Can not read the results (StartX, StartY, EndX, EndY, Length, ParcelSegment )

As shown below, i would like to show the result in TextBox14

 

 

Private Sub ToggleButton3_Click()
' Loop through all elements used to make parcel "oParcel"
UserForm1.Hide
Dim i As Integer
Dim vPt As Variant
Dim oEnt As AcadEntity

Dim oLblSrc As AeccParcelSegmentLabel
Dim oLblDest As AeccParcelSegmentLabel
Dim oElement As AeccParcelSegmentElement

ThisDrawing.Utility.GetEntity oEnt, vPt, vbCr & "Selecione a confrontação a direita: "
If TypeOf oEnt Is AeccParcelSegmentLabel Then
Set oLblsrc=oEnt
ThisDrawing.Utility.GetEntity oEnt, vPt, vbCr & "Select label to "
If TypeOf oEnt Is AeccParcelSegmentLabel Then
Set oLblDest = oEnt
oLblDest.LineLabelStyle = oLblSrc.LineLabelStyle
End If
Debug.Print "Element " & i _
& " of segment " & oElement.ParcelSegment.Name & ": " _
& oElement.StartX & "," & oElement.StartY & " to " _
& oElement.EndX & ", " & oElement.EndY


If (TypeOf oElement Is AeccParcelSegmentLine) Then
Dim oSegmentLine As AeccParcelSegmentLine
Set oSegmentLine = oElement
Debug.Print " is a line. "
ElseIf (TypeOf oElement Is AeccParcelSegmentCurve) Then
Dim oSegmentCurve As AeccParcelSegmentCurve
Set oSegmentCurve = oElement
Debug.Print " is a curve with a radius of:" _
& oSegmentCurve.Radius
End If
End If


TextBox14 = oElement.EndX
UserForm1.show
End Sub

Message 5 of 11
Jeff_M
in reply to: ramd401

@ramd401, I don't see where you are setting the oElement. The Label object in COM does not have a way to obtain the object it is labeling (.NET does). As long as you can get the actual ParcelSegmentElement, then you will be able to show the data you wish to see. 

 

Can you zip up the DVB you are using to allow us to look over the actual code you are testing with?

Jeff_M, also a frequent Swamper
EESignature
Message 6 of 11
ramd401
in reply to: Jeff_M

Hi Jeff the thing is that i do not know how to setting the oElement in it, can you give me a hand where to do that?

 

 

Rosario Dilo 

Message 7 of 11
ramd401
in reply to: ramd401

Ataching the file

Message 8 of 11
Jeff_M
in reply to: ramd401

Thanks for the file. It appears that you are piecing together different snips of code. Unfortunately, I don't read the language you've used on the form, you didn't name the controls so they would be easy to locate in the code, and it has been way too long since I've done any work in VBA. I spent about an hour on it before I had to give up. Perhaps Augusto will be able to help a bit more.

Now, If you'd be willing to move to .NET, and c# in particular, I'd have a better chance of lending a hand.
Jeff_M, also a frequent Swamper
EESignature
Message 9 of 11
ramd401
in reply to: Jeff_M

Hi, As i mentioned in the first post iam still new im VBA nevertheless iam still working on the project giving name in the commnads and organize the codes. So the botton i need help now is the one with description "Ler esq." (I mean read the left segment label " L1 ") it has already the codes so when i click the segment label i would like it to see in the Textbox14 the (Start easting, start northing, length, azimuth, end easting and end northing).

 

After that as i sad i can start rewrite the macros with more organization and proper name for comboboxes, textboxes and others.

 

Remember: for the moment i need help for the botton i have mentioned before.

 

 

Rosario Dilo

Regards

Message 10 of 11
Jeff_M
in reply to: ramd401

OK, but I don't think you can get what you need from the Label. In the COM API the Label has no direct link to the object being labeled, nor does it have a property or method which exposes the contents of the label.
Jeff_M, also a frequent Swamper
EESignature
Message 11 of 11
ramd401
in reply to: Jeff_M

So in this case, do you think i can get this results from polylines or lines?

 

If So what do you sugest as macro?

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report