AutoCAD Architecture Customization

AutoCAD Architecture Customization

Reply
Contributor
faugustom
Posts: 15
Registered: ‎12-07-2009
Message 1 of 11 (200 Views)

VB code to detect if a project is loaded

200 Views, 10 Replies
12-07-2012 05:19 PM

Hi all!

 

There is a way to detect is a project is loaded using PSD VB code?

 

Thank's

*Expert Elite*
Keith.Brown
Posts: 1,120
Registered: ‎03-13-2008
Message 2 of 11 (197 Views)

Re: VB code to detect if a project is loaded

12-07-2012 06:01 PM in reply to: faugustom

You don't even need vb script in the property set.  Just create a project property definition and choose the Project Name.  If a project is loaded it will contain the name otherwise it will say *NO PROJECT*


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!
Contributor
faugustom
Posts: 15
Registered: ‎12-07-2009
Message 3 of 11 (191 Views)

Re: VB code to detect if a project is loaded

12-08-2012 02:02 AM in reply to: faugustom
HI Keith;

That's exactely my problem! I have a formula property let's Day " A + B". "A" is a Project property. If a Project os loaded, the result is OK, but if not, the formula doesn't work because the "*No project*". So I want a code "If result else" to give a value bases if a Project os loaded ir not. Thank's!
Contributor
faugustom
Posts: 15
Registered: ‎12-07-2009
Message 4 of 11 (189 Views)

Re: VB code to detect if a project is loaded

12-08-2012 02:15 AM in reply to: faugustom
Something like this:

If project loaded = yes
result = A + B
else
result = B
*Expert Elite*
Keith.Brown
Posts: 1,120
Registered: ‎03-13-2008
Message 5 of 11 (181 Views)

Re: VB code to detect if a project is loaded

12-08-2012 05:25 AM in reply to: faugustom

Create two project definitions, the first would be the previous one that I mentioned.  The second will be a formula based definition and enter in something like this.

 

If [PROJECT NAME] = "*no name*" then

     RESULT = B

Else

     RESULT = A + B

End If

 

For [PROJECT NAME] select the the project definition created in step one.

 

This should give you the results you want as long as you don't name any of your projects "*no name"!  Also you should be aware that vb script is case sensitive so make sure that the case of your letters is correct.


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!
Contributor
faugustom
Posts: 15
Registered: ‎12-07-2009
Message 6 of 11 (176 Views)

Re: VB code to detect if a project is loaded

12-08-2012 04:40 PM in reply to: Keith.Brown

Hi Keith!

 

Thank's for the answer, but this doesn't work... if there is any project related property in any level of the PSD formula, the result showed is *No project* in every property.... that's why I'm asking for a alternative without using a direct project related property... Thank's!

*Expert Elite*
Keith.Brown
Posts: 1,120
Registered: ‎03-13-2008
Message 7 of 11 (171 Views)

Re: VB code to detect if a project is loaded

12-08-2012 05:07 PM in reply to: faugustom
It will work. You just need to encapsulate everything in an if then statement to see if the project is loaded. If it is not loaded you can set it to a null string.

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!
Contributor
faugustom
Posts: 15
Registered: ‎12-07-2009
Message 8 of 11 (168 Views)

Re: VB code to detect if a project is loaded

12-08-2012 05:24 PM in reply to: Keith.Brown

Hi again Keith!

 

I've attached a sample file, can you please see what I'm doing wrong?

Thank's

*Expert Elite*
Keith.Brown
Posts: 1,120
Registered: ‎03-13-2008
Message 9 of 11 (156 Views)

Re: VB code to detect if a project is loaded

12-10-2012 09:09 AM in reply to: faugustom

faugustom,

 

I was incorrect it appears.  The only other thing I can think of is to create two property sets.  One for projects and one that doesnt contain projects that read the same information.  Another option would to use the .net api and set the property defintions manually instead of using formulas.  This would allow you to check and see if a project is loaded and then do the appropriate action and then fill in the manual property set with the correct information.  You could lock the property set so no one could modify the information.

 

Sorry but that is the only options I can think of at this time.

 

 


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!
Contributor
faugustom
Posts: 15
Registered: ‎12-07-2009
Message 10 of 11 (148 Views)

Re: VB code to detect if a project is loaded

12-11-2012 02:29 AM in reply to: Keith.Brown

Hi Keith!

 

yep, i'm creating two PSD, two sets of tags.... I don't know .net, so still waiting for someone's light!

Thank you very much for the help!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.