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

mass element "elevation" in property set

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
pjguerin
1309 Views, 19 Replies

mass element "elevation" in property set

Hi,

i'm looking a way to extract the elevation of a mass element in a property set :
Pb : i find an "automatic property data" called "elevation" in the right property data set, but it doesn't work !
It marks "N/A" in the field.
Therefore i can find th right information on the "conception tab".

If someone knows something !!!???
19 REPLIES 19
Message 2 of 20
TotalMech
in reply to: pjguerin

These posts will help see how you can get to the "other" properties of objects. Mass elements are similar. You can use code similar to what you will find in these posts to extract the "location" property and then subtract 1/2 the hieght...



http://discussion.autodesk.com/forums/click.jspa?searchID=9554063&messageID=5578017



http://discussion.autodesk.com/forums/click.jspa?searchID=9554063&messageID=5397791




it works...
Message 3 of 20
pjguerin
in reply to: pjguerin

thx a lot for your help
I finally found how to get this value.
I opens now a lot of new possibilities.

Super !!!

PJ
Message 4 of 20
jalcarazsd
in reply to: pjguerin

Can you please share the answer. The links on post 2 of 3 do not take me there.

 

Thank you.

Message 5 of 20
Keith.Brown
in reply to: jalcarazsd

Message 6 of 20
Keith.Brown
in reply to: Keith.Brown

Here is the actual completed code that I used in the property set to get the location of the mass element.

 

On Error Resume Next
DecimalPlaces = 3
Set acadApp = GetObject(,"AutoCAD.Application") 

'ACADVER values:
'ACA 2010 = "18.0s (LMS Tech)" 
'ACA 2011 = "18.1s (LMS Tech)"
'ACA 2012 = "18.2s (LMS Tech)"
'ACA 2013 = "19.0s (LMS Tech)" 
'ACA 2014 = "19.1s (LMS Tech)" 
'ACA 2015 = "20.0s (LMS Tech)" 

acadVerString = acadApp.ActiveDocument.GetVariable("ACADVER")

'Set ACA application string, based on version running: 
Select Case acadVerString 

	Case "18.0s (LMS Tech)"  'ACA-2010 
		aecBaseVer = "AecX.AecBaseApplication.6.0" 

	Case "18.1s (LMS Tech)"  'ACA-2011 
		aecBaseVer = "AecX.AecBaseApplication.6.5" 

	Case "18.2s (LMS Tech)"  'ACA-2012 
		aecBaseVer = "AecX.AecBaseApplication.6.7"

	Case "19.0s (LMS Tech)"  'ACA-2013 
		aecBaseVer = "AecX.AecBaseApplication.7.0"

	Case "19.1s (LMS Tech)"  'ACA-2014 
		aecBaseVer = "AecX.AecBaseApplication.7.5"

	Case "20.0s (LMS Tech)"  'ACA-2015 
		aecBaseVer = "AecX.AecBaseApplication.7.7"

	Case Else 
		aecBaseVer = "Unknown" 

End Select 

If aecBaseVer = "Unknown" Then 
	RESULT = "Unknown Version" 
Else
	Set aecBase = acadApp.GetInterfaceObject(aecBaseVer)
	aecBase.Init acadApp
	Set MassElementObject = acadApp.ActiveDocument.ObjectIDToObject([ObjectID])
	Set UtilityObject = aecBase.ActiveDocument.Utility

	' Get the Normal of the Object and break down into individual X, Y, and Z parts
	MassElementObjectNormal = UtilityObject.ConvertToVariantArray(MassElementObject.Location)
	NormalX = Round(MassElementObjectNormal(0), DecimalPlaces)
	NormalY = Round(MassElementObjectNormal(1), DecimalPlaces)
	NormalZ = Round(MassElementObjectNormal(2), DecimalPlaces)

	'Return the results
       RESULT = CStr(NormalX & ";" & NormalY & ";" & NormalZ)


End If

 

Just remember to replace the [ObjectId] with the actual automatic property definition.  I tested it on MEP 2013, 2014, 2015 and it worked in all versions.

 

I have included the dwg with the MASSELEMENT property set definition attached to the post.

 

 

Message 7 of 20
Keith.Brown
in reply to: Keith.Brown

One more thing that I thought I should mention.  This method will only work if you have 1 instance of AutoCAD MEP running.  If you open up a second instance then the property set will fail.

Message 8 of 20
jalcarazsd
in reply to: Keith.Brown

Keith,

 

First of all...Thank you for responding.

I am having trouble  with replacing the [ObjectId] with the actual automatic property definition. I have attached a picture of what I am working with. Please advise.property sets.PNG

 

Message 9 of 20
jalcarazsd
in reply to: Keith.Brown

I apologize...I am running MEP 2012 for this particular drawing. All others are 2014.
Message 10 of 20
Keith.Brown
in reply to: pjguerin

You need to create the ObjectId as an automatic property definition in your property set and then reference it in the formula definition that I supplied above.

So find the [ObjectId] in the formula I supplied and then delete it and in its place put the automatic property. I'm on my mobile now so I can't upload a video but please read the link I posted above. It should explain it.

A working example is attached to my post above.
Message 11 of 20
Keith.Brown
in reply to: pjguerin

Then open my drawing in 2013 and recreate your property set to see how it works in 2013. Then recreate in 2012. Just have 1 Autocad open at once.
Message 12 of 20
Keith.Brown
in reply to: pjguerin

Oops said 2013 but meant 2014.
Message 13 of 20
jalcarazsd
in reply to: Keith.Brown

Got it!
My day is coming to an end. I will continue tomorrow. We have a lot of fires going on , here in the West coast
Message 14 of 20
Keith.Brown
in reply to: jalcarazsd

Glad you got it working.  For anyone else reading this thread and wanting an answer, I modified the code above to better reflect the elevation and not the location.  The code is below as well as a drawing that has the working property set.

 

On Error Resume Next
DecimalPlaces = 8
Set acadApp = GetObject(,"AutoCAD.Application") 

'ACADVER values:
'ACA 2010 = "18.0s (LMS Tech)" 
'ACA 2011 = "18.1s (LMS Tech)"
'ACA 2012 = "18.2s (LMS Tech)"
'ACA 2013 = "19.0s (LMS Tech)" 
'ACA 2014 = "19.1s (LMS Tech)" 
'ACA 2015 = "20.0s (LMS Tech)" 

acadVerString = acadApp.ActiveDocument.GetVariable("ACADVER")

'Set ACA application string, based on version running: 
Select Case acadVerString 

	Case "18.0s (LMS Tech)"  'ACA-2010 
		aecBaseVer = "AecX.AecBaseApplication.6.0" 

	Case "18.1s (LMS Tech)"  'ACA-2011 
		aecBaseVer = "AecX.AecBaseApplication.6.5" 

	Case "18.2s (LMS Tech)"  'ACA-2012 
		aecBaseVer = "AecX.AecBaseApplication.6.7"

	Case "19.0s (LMS Tech)"  'ACA-2013 
		aecBaseVer = "AecX.AecBaseApplication.7.0"

	Case "19.1s (LMS Tech)"  'ACA-2014 
		aecBaseVer = "AecX.AecBaseApplication.7.5"

	Case "20.0s (LMS Tech)"  'ACA-2015 
		aecBaseVer = "AecX.AecBaseApplication.7.7"

	Case Else 
		aecBaseVer = "Unknown" 

End Select 

If aecBaseVer = "Unknown" Then 
	RESULT = "Unknown Version"
Else
	Set aecBase = acadApp.GetInterfaceObject(aecBaseVer)
	aecBase.Init acadApp
	Set MassElementObject = acadApp.ActiveDocument.ObjectIDToObject([ObjectID])
	Set UtilityObject = aecBase.ActiveDocument.Utility

	' Get the Normal of the Object and break down into individual X, Y, and Z parts
	MassElementObjectNormal = UtilityObject.ConvertToVariantArray(MassElementObject.Location)
	NormalX = Round(MassElementObjectNormal(0), DecimalPlaces)
	NormalY = Round(MassElementObjectNormal(1), DecimalPlaces)
	NormalZ = Round(MassElementObjectNormal(2), DecimalPlaces)

	'Return the results
       RESULT = Cdbl(NormalZ)


End If

 

Message 15 of 20
jalcarazsd
in reply to: Keith.Brown

Keith, I attached a snapshot of what I encountered. I do not have Z elevation for some reason, the result is still the whole formula. Please advise.

Message 16 of 20
Keith.Brown
in reply to: jalcarazsd

First I see is that you replaced the ObjectId incorrectly.

 

you have:  

 

Set MassElementObject = acadApp.ActiveDocument.ObjectIDToObject[ObjectID]

 

and it should be

 

Set MassElementObject = acadApp.ActiveDocument.ObjectIDToObject([ObjectID])

Notice the parenthesis that you have missing?

 

Second you should format the code correctly.  While techniqually not an issue it is difficult to read and to maintain.  What happens when you need to come back to it in 2 months and you need to read and understand what you did?  Good luck with that.  Smiley Happy

 

 

 

 

Message 17 of 20
jalcarazsd
in reply to: jalcarazsd

Here is the actual drawing. MEP 2014 and a snapshot.

Message 18 of 20
jalcarazsd
in reply to: jalcarazsd

With or without parenthesis, still says unknown version..
Message 19 of 20
Keith.Brown
in reply to: jalcarazsd

Here you go.

 

FYI.  All i did was copy the code from the drawing i supplied to the drawing you supplied, changed the ObjectID, and then set the units.

 

p.s.  You must only have one AutoCAD open at a time or this will not work.

 

 

Message 20 of 20
jalcarazsd
in reply to: Keith.Brown

It works!!!

 

Keith, I truly appreciate that you took the time to help. 

 

Thank you for that. Have a great weekend.

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

Post to forums  

Autodesk Design & Make Report

”Boost