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: 

VBA Script

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
mrivera
882 Views, 15 Replies

VBA Script

I am wondering if there is a way to make script that shows up in a schedule that will allow you to report a size for a MEP pipe fitting in a certain way for different fittings.  I want to have one column to show sizes instead of 3 columns in case I have a reducer or a tee or wye.  For example if I have a 4" elbow, I want it to show only the connection 1 diameter as 4".  If I have a 4" tee I want it to say 4".  If I have a reducer that is 4x3, I would like it to report in the 1 column as 4x3, but reporting the connection 1 and 2 diameter.  I also would like to have a reducing tee that is 4x4x3 report in 1 column, but reports the Nominal connection diameter for 1, 2 & 3.  Can this be done or am I out of luck?  If this is confusing pleasel let me know.

15 REPLIES 15
Message 2 of 16
VitalyF
in reply to: mrivera

Hi,

 

 

You can attach an example of the expected table?

It would be easier to understand what you need.

 

 

Vitaly

Message 3 of 16
mrivera
in reply to: VitalyF

Here is what I am tring to do, but don't know how to have it just show the 6x6x4 on the combination or just  4 on the coupling.  

Message 4 of 16
VitalyF
in reply to: mrivera

Hi,

 

Try this formula

 

ND = Replace( "[NominalDiameter]", ".", "," )
Select Case "[PartType]"
	Case "TRANSITION"
		RESULT =  CDbl(Split(ND, ";", -1, 0) (0))&" x "&CDbl(Split(ND, ";", -1, 0) (1))
Case "ELBOW"
		RESULT =  CDbl(Split(ND, ";", -1, 0) (0))&" x "&CDbl(Split(ND, ";", -1, 0) (1))
Case "TEE"
		RESULT =  CDbl(Split(ND, ";", -1, 0) (0))&" x "&CDbl(Split(ND, ";", -1, 0) (1))&" x "&CDbl(Split(ND, ";", -1, 0) (2))
Case "CROSS"
		RESULT =  CDbl(Split(ND, ";", -1, 0) (0))&" x "&CDbl(Split(ND, ";", -1, 0) (1))&" x "&CDbl(Split(ND, ";", -1, 0) (2))&" x "&CDbl(Split(ND, ";", -1, 0) (3))

	Case Else
		RESULT = CDbl(Split(ND, ",", -1, 0) (0))
 End Select

This is the result, you can add other elements in the formula

 

PipeSize.gif

 

Regards,

 

Vitaly

Message 5 of 16
mrivera
in reply to: VitalyF

That worked, thanks. The only problem I have now is that it adds 0's to the end. I can't figure out what setting that is.1.jpg

Message 6 of 16
VitalyF
in reply to: mrivera

Hi,

 

Attach your file, please

 

Vitaly

Message 7 of 16
mrivera
in reply to: VitalyF

Here you go.

Message 8 of 16
VitalyF
in reply to: mrivera

Hi,

 

On my PC looks right. Try MEP template out of the box.

You used the Imperial profile?

 

PipeSize_1.gif

 

Vitaly

Message 9 of 16
mrivera
in reply to: VitalyF

I do use the imperial one and when I opened your drawing it shows the same.
Message 10 of 16
VitalyF
in reply to: mrivera

 

 

While I do not know what to think ...

Message 11 of 16
mrivera
in reply to: VitalyF

You have the units as standard in each field?  What do you have in the property data formats?

Message 12 of 16
VitalyF
in reply to: mrivera

 

 

Yes, I use the data format - Standard MEP 2016

Message 13 of 16
mrivera
in reply to: VitalyF

Well I'm trying different things to get it to work correctly, but nothing yet.  I will keep on working on it.  I really appreciate the help on solving the problem of reporting the sizes.  Thanks again for helping.  Where did you learn how to use the VBA scripting?

Message 14 of 16
VitalyF
in reply to: mrivera

I have learned from this and other forums Autodesk

Autodesk, thank you!

 

 

Regards,

 

Vitaly

Message 15 of 16
Keith.Brown
in reply to: VitalyF

I get most of my general VBScript information from this site.  http://www.w3schools.com/vbscript/  While it does not contain any AutoCAD MEP specific information it is good for general stuff.

 

 

Message 16 of 16
VitalyF
in reply to: Keith.Brown

Hi Keith,

 

If you are the administrator of this topic, please correct Kudos

The solution is this script Try this formula  ))

 

 

Best regards,

 

Vitaly

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

Post to forums  

Autodesk Design & Make Report

”Boost