TheSwamp

Code Red => VB(A) => Topic started by: DIW_CADtech on May 18, 2011, 10:39:27 PM

Title: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 18, 2011, 10:39:27 PM
It's been 13 years since i've done any VB... and mixing with AutoCAD isn't making it easier...

So here's what i'm trying to do...
I am trying to create a Bill of Materials schedule that lists everything in the 3d model...
3 coluns..
MK#  (reference line item number to bid sheet)(this is hand typed no automation here)
Quantity (simple quantity)
Description (posting the style of the object)

However,  the correct output for the DESCRIPTION objects would be  [cutlength][style][gaged] or [nom length][style] or if it's not pipe(i.e. has no cutlength) just [style]

To acomplish this....
I wanted to create an if then statement in the schedule in a formula column and or dataset formula type that first tests if the item is a pipe.

I can view the Extended Data of any object with the PropertySetDefininition attached and i see "?" for any item that is not a pipe

So I tried and if then statement to check fro "?" it   rusult was the whole code posted as text.. so fail
So I tried IsNumaric( [length] )=True rusult was the same as above
So i tried [length]=Nothing ... same as above
So i tried IsNul ( [length] ) = True ... code seemed to work however all items posted as having values.. which is false  fittings should have failed
So I tried [length]=Empty... posted code

I need to get this first check to work before i can use and if then or else statement to post the correct of 3 concatenated strings.
So essentially this is a check on the variable/property [length] or [cutlength]  

need some help  
Any suggestions?
Is there another way?  A better way?

Help.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff_M on May 18, 2011, 11:07:00 PM
Dumb question, what product is this for?

Possible more dumb questions to follow....

OK, I now see that you seem to be a one man posting crew in the ABS forum :-) So I think this must be for MEP? I'm not familiar with MEP, yet, but I'll have a look as soon as I can.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff H on May 18, 2011, 11:38:48 PM
I am pretty sure he is talking about the VB script editor in Style manager..... MEP, ARCH etc..........

Load up drawing with info, but I think what you want would not be too difficult

Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 18, 2011, 11:55:38 PM
Yes,
This is how I started.. see the following code... I thought I was really onto something then  it failed... see following picture... all items that do not begin with 110  are fittings/accesories/valves or other items that do not have [cutlength]  thus they get populated differently... so this check fails to deliver desired results.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 12:03:30 AM
The desired end result is concatonating the appropriet data into different datasetdefinitions and posting those as a result

i.e.
Result = [NomStyle]
Result = [GuagedStyle]
or
Result = [Style]

If [length] = 217.5 Then
     Result = [NomStyle]
ElseIf [length] < 217.5 Then
     Result = [GuagedStyle]
Else
     Result = [Style]
endif

However... the previous code posted above fails on non pipe items... so need a different check on [length]
i have tried
IsEmpty
IsNumaric
 []=Nothing
IsNul

and have similar results.. seems to work on the pipe, but on the other items.. it ether posts the "NOminal" or "Guaged" statement... or it posts the full code in the cell.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 12:06:55 AM
see attached autocad MEP 2012 file....
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 02:32:41 AM
Noticed the file doesn't post for those not logged in....
http://dl.dropbox.com/u/20790817/testing.dwg
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff_M on May 19, 2011, 04:40:21 PM
So is this what you are looking for?
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 04:51:02 PM
YESS.... what is different?
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 04:52:13 PM
JEFF M your my HERO!
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 06:39:46 PM
OK.. now I can't get the concatination to work...

For "Post Style"  I want to post just the [Style] variable

For "Nominal"  I want to post "Nominal 18' X " & [Style]
example output Nominal 18' X 12 INCH DI MECH JOINT-TYTON JOINT CEMENT MORTAR LINED ASPHALT COATED

For "Guaged" I want to post "FC " & [CLSTRING] & " " & [Style] & " (Guaged)"



So with that goal in minde I created a formula based DataSetDefinition for [Style2] and [Style3]
 
[Style2]
RESULT = "18' Nominal " & [Style]

[Style3]
RESULT = "FC " & [CLSTRING] & " " & [Style] & " (GUAGED)"

I think that [Style3] is the problem but no easy way to debug... 
or maybe I'm going at this the entirely wrong way?
Should I just include these concatonations inside of the results in the [LengthCheck] DataSetDefinition?

File
http://dl.dropbox.com/u/20790817/testing02.dwg

see also image attached.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 06:52:02 PM
So I also tried modifying the [LengthCheck]

Same same... it doesn't work correctly..

http://dl.dropbox.com/u/20790817/testing03.dwg

Maybe i'm using RESULT =  incorrectly?
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff H on May 19, 2011, 07:21:40 PM
The title is still wrong but is this what you are looking for?


Had to delete one object and double click in bottom left window

Had to place parentheses correctly in Style2 and style3 and other function

If what you are looking for since drawing is 3MB and I have dropbox can I load it up to your dropbox
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 07:54:06 PM
Yes, but not sure how to help you do that.. I'm new to DropBox  Not sure how to facilitate that.. waht do you need from me?  and it needs to be a different file name since it's posted in the forum.. don't want to confuse the crap out of people....
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 08:00:22 PM
you can also post it here and i can put it in my dropbox and paist the link in the forum

https://waterworks.hdsupply.com/fileshare/

just let me know.. it will evaporate after 24 hours.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff H on May 19, 2011, 08:04:21 PM
Just figured out how to do public links with dropbox
 and when you get it and it works let me know and I will remove it from mine since it is almost full

*******************************Edit**********************
Removed old file link
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 09:22:22 PM
This is soo CLOSE...

I need to work out the lengths... they need to post in feet and inches

i.e.  120 = 10'-0"

Link to the current file is.....
http://dl.dropbox.com/u/20790817/testing04.dwg


thanks again Jeff
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff H on May 19, 2011, 09:52:49 PM
Quickest way and if just wanting to show in schedule.

---Select schedule
---Edit Style
---Select Length Column
---Modify
---Change Data Format
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff H on May 19, 2011, 10:00:51 PM
Next step is to get Jeff_M away from Civil and into MEP so we would have someone to teach us VB and how to use MEP .NET API
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: Jeff_M on May 19, 2011, 10:08:40 PM
Now that is humorous and flattering :-) Although in my brief perusal of MEP (20 minutes or so) I'm seeing things I wish we had IN C3D. I'm leaving on a 2+ week vacation Sunday, perhaps I'll find some time to play around in the MEP world.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 10:21:16 PM
http://dl.dropbox.com/u/20790817/testing05.dwg

The point is to only have 3 columns
and the proper format for the length in the Description is feet and inches

i.e. 120 = 10'-0"

I have the extra columns because i'm trying to understand how it works, but I don't want those.

Need to get it into the description correctly.  I hope this is still possible.
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 10:22:05 PM
Seriously.. the more people in the MEP forum  the better...  feel like I'm swimming with weights...
Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 19, 2011, 10:47:14 PM
Unit Feet and inches does NOT seem to work either.. it seems to round to the nearest foot and does not include the marks ( ' ) or ( " )

Title: Re: Schedules - Forulas - VB if then statement to check object is pipe HELP
Post by: DIW_CADtech on May 20, 2011, 02:35:54 AM
I even tried to break out the feet inches and 1/16ths to seperate DataSetDefinitions from the [length] and then concatenate them in a DataSetDefinition [PIPELEN] 

I did have to use Chr(34) Chr(39) and Chr(47)  and it worked as a stand alone.. but once I introduced [PIPELEN] as a separate column... pthh... it went bust

So never got it to concatinate in the first place...

I'm bushed... calling it a night...
http://dl.dropbox.com/u/20790817/testing06.dwg    is the polished ver of 5

http://dl.dropbox.com/u/20790817/testing07.dwg    is my foolish attempt at using Chr()

take a look... or skip if you have a better idea and post that....