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: 

Formulas

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
tim-bot
933 Views, 9 Replies

Formulas

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!

9 REPLIES 9
Message 2 of 10
Keith.Brown
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.

Message 3 of 10
tim-bot
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?

Message 4 of 10
Keith.Brown
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.

Message 5 of 10
tim-bot
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.

Message 6 of 10
Keith.Brown
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!!! 

Message 7 of 10
tim-bot
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.

 

Message 8 of 10
tim-bot
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.

Message 9 of 10
Keith.Brown
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.

Message 10 of 10
tim-bot
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

 

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

Post to forums  

Autodesk Design & Make Report

”Boost