AutoCAD MEP General Discussion

Reply
Active Contributor
tim-bot
Posts: 49
Registered: ‎02-13-2009
Message 1 of 10 (580 Views)
Accepted Solution

Formulas

580 Views, 9 Replies
08-10-2012 01:01 PM

Can someone give me a pointer as to what i'm doing wrong? i'm trying to do a formula, in Schedules or in Property Set Definitions, but instead of getting the result, all i'm getting is the formula text itself. i've tried a number of things like [Item] * 2, RESULT = [Item] * 2, Function X() X = [Item] * 2 End Function RESULT = X(). everything like that, but it's like it's just not executing, what am i doing wrong? the value for [Item] comes in as a number, but the math just never executes... really starting to irritate me... thanks!

This is what I would usually do in a situation like this.  Create the automatic property Object Type.  Make sure your property set applies to both mvparts and structural members.

 

 

Select Case UCase("[Object Type]")

Case "STRUCTURAL MEMBER"
RESULT = [Material Requisition:Style]
Case "MULTI-VIEW PART"
RESULT = [Material Requisition:Name]
CASE Else
RESULT = "** ERROR Name Not Found !!**"

End Select

 

This is one way to do what you are trying to accomplish.  It also gives you the flexibility of adding other styles very easily and is a little better to read then if/then/else statements.

*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 2 of 10 (572 Views)

Re: Formulas

08-10-2012 01:25 PM in reply to: tim-bot

Hi tim-bot,

 

It sounds to me like you probably have a units conflict.

 

Your first two attemps should have worked but since they didnt they we should assume that something is incorrect with your units.  Items should be a number an not text.  Just because it looks like a number doesnt mean that it actually is. You can cast it as a integer by doing something like the following.

 

RESULT = CInt([Item]) * 2

 

Also you should make sure that you are not manually typing in  [Item] but are instead picking it from the list.  If you type it then your formula will most definately fail.


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
Active Contributor
tim-bot
Posts: 49
Registered: ‎02-13-2009
Message 3 of 10 (570 Views)

Re: Formulas

08-10-2012 01:30 PM in reply to: Keith.Brown

Thanks for the suggestion, unfortunatly i've tried doing all sorts of type conversions already to no avail. it's like there's a variable set that is keeping formulas from being evaluated or something. yeah, i'm double clicking on the field in the list, and the funny thing is that in the properties palette or in the schedule, the numbers actually come in, just the formula isn't evaluated... i'm on x64, that shouldn't be an issue would it? maybe i need to install the VBA stuff?

*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 4 of 10 (567 Views)

Re: Formulas

08-10-2012 01:34 PM in reply to: tim-bot

Nah,  it has nothing to do with VBA.

 

Is it possile to post a sample file?  That would be the best or even post a screen shot of what your formula looks like?

 

I am working on a property set now that has over three hundred property definitions that are formula based that do the same kind of thing that you are working on and they are working without an issue.  So it just has to be something simple that is being overlooked.

 

If you could post the file it would be much quicker to solve the issue.  It doesnt have to be a complete file, just something with an object and the property set you are working on.


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
Active Contributor
tim-bot
Posts: 49
Registered: ‎02-13-2009
Message 5 of 10 (564 Views)

Re: Formulas

08-10-2012 01:38 PM in reply to: Keith.Brown

here you go, thanks for looking at this. it's happening on all my drawings though, so i'm guessing there's a global setting of some sort. this has just a few very simple formulas that don't work. originally i was actually trying to do an if then statement to get proper values, but nothing is working.

*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 6 of 10 (556 Views)

Re: Formulas

08-10-2012 01:50 PM in reply to: tim-bot

well, this is something your not going to want to hear but it is working just fine when I opened it up. 

 

Property Set Test.jpg

 

 

So now I am really confused.  I dont have the VBA Module installed for 2013 so I am pretty sure that is not the problem.  It is hard for me to figure out what is wrong if nothing appears to be wrong on my system!!! 


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
Active Contributor
tim-bot
Posts: 49
Registered: ‎02-13-2009
Message 7 of 10 (553 Views)

Re: Formulas

08-10-2012 01:53 PM in reply to: Keith.Brown

i was afraid of that... might try and reset my autocad to see if that gets it working, otherwise, i'm not sure... thanks for helping and confirming my system is jacked. i'll let you know if resetting helps.

 

Active Contributor
tim-bot
Posts: 49
Registered: ‎02-13-2009
Message 8 of 10 (544 Views)

Re: Formulas

08-10-2012 03:18 PM in reply to: tim-bot

Reinstalling autocad seems to have helped. another question, anyway to be able to do a formula to test the object type and return the relevent value?

I'm trying to apply a schedule to some structural members (Unistrut) and also some multi-view blocks (Pipe Clamps)

 

If [Material Requisition:Style]=? Then
	'If Style is missing, It must be a Multi-View Block
	'Return the Multi-View Block Name
	RESULT = [Material Requisition:Name]
Else
	'If Style exists, It must be a Structural Member
	'Return Structural Member Style
	RESULT = [Material Requisition:Style]
End If

 This just returns the formula as a string.

*Expert Elite*
Keith.Brown
Posts: 1,180
Registered: ‎03-13-2008
Message 9 of 10 (541 Views)

Re: Formulas

08-10-2012 03:41 PM in reply to: tim-bot

This is what I would usually do in a situation like this.  Create the automatic property Object Type.  Make sure your property set applies to both mvparts and structural members.

 

 

Select Case UCase("[Object Type]")

Case "STRUCTURAL MEMBER"
RESULT = [Material Requisition:Style]
Case "MULTI-VIEW PART"
RESULT = [Material Requisition:Name]
CASE Else
RESULT = "** ERROR Name Not Found !!**"

End Select

 

This is one way to do what you are trying to accomplish.  It also gives you the flexibility of adding other styles very easily and is a little better to read then if/then/else statements.


Keith Brown AutoCAD MEP BLOG | RSS Feed
AutoCAD MEP 2014 | Revit 2014 | EastCoast CAD/CAM V6.1 | Visual Studio 2013
────────────────────────────────────
⁞|⁞ Please use Mark Solutions!.Accept as Solution and Give Kudos!Give Kudos as appropriate. Thank you!
Active Contributor
tim-bot
Posts: 49
Registered: ‎02-13-2009
Message 10 of 10 (481 Views)

Re: Formulas

08-13-2012 10:00 AM in reply to: Keith.Brown

that's perfect thanks, got it all working, just had to add some quotes around the result and everything started falling into place!

 

Select Case LCase("[Material Requisition:ObjectType]")
	Case "structural member"
		RESULT = "[Material Requisition:Style]"
	Case "multi-view block reference"
		RESULT = "[Material Requisition:Name]"
	Case Else
		RESULT = ""
End Select

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions to get help installing your software.

New AutoCAD MEP Category!

The AutoCAD MEP forum has moved into it's very own category page, and can no longer be found within the Additional Product Forums.