<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Industrial Piping Design Blog...and other stuff</title>
	<atom:link href="http://www.davetyner.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davetyner.com</link>
	<description>Award Winning Plant Industry Community and the Birthplace of Project X</description>
	<lastBuildDate>Wed, 19 Jun 2013 20:04:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Improve Viewport Performance with the DWG to 3DS Max Block Cleaner</title>
		<link>http://www.davetyner.com/2013/06/improve-viewport-performance-with-the-dwg-to-3ds-max-block-cleaner/</link>
		<comments>http://www.davetyner.com/2013/06/improve-viewport-performance-with-the-dwg-to-3ds-max-block-cleaner/#comments</comments>
		<pubDate>Wed, 19 Jun 2013 17:04:00 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Autodesk 3DS Max]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[3DS max]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[cleaner]]></category>
		<category><![CDATA[improve]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[scene]]></category>
		<category><![CDATA[viewport]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=2414</guid>
		<description><![CDATA[AKA Optimize Your 3DS Max/Design Scene!! AKA One Of The Most Important Things To Do After Importing DWG Files Into 3DS Max/Design Importing DWG CAD files efficiently is one of 3DS Max&#8217;s many bright spots. Unfortunately, the import will bring across some junk that will, depending on the complexity of your scene, significantly slow down [...]]]></description>
			<content:encoded><![CDATA[<h4 class="cufon">
<p>AKA Optimize Your 3DS Max/Design Scene!!</p>
</h4>
<h4 class="cufon">
<p>AKA One Of The Most Important Things To Do After Importing DWG Files Into 3DS Max/Design</p>
</h4>
<p>Importing DWG CAD files efficiently is one of 3DS Max&#8217;s many bright spots. Unfortunately, the import will bring across some junk that will, depending on the complexity of your scene, significantly slow down your viewport. I use this script to clean up those files. The difference in viewport/render performance after running this utility is like going&#8230;</p>
<h4 class="cufon">from this:</h4>
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/06/donkey-w-cart1.jpg" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/06/donkey-w-cart1.jpg&amp;h=233&amp;w=200&amp;zc=1" alt=""/></a></div>
<p><br class="clear" /></p>
<h4 class="cufon">to this:</h4>
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/06/donkey.jpeg" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/06/donkey.jpeg&amp;h=233&amp;w=200&amp;zc=1" alt=""/></a></div>
<p><br class="clear" /></p>
<p>This utility compliments my <a href="http://www.davetyner.com/2013/03/polyform-importer-the-dwg-batch-importer-for-3ds-max-and-3ds-max-design/">DWG Batch Importer</a> script nicely. However, you don&#8217;t need that utility for this one to work.</p>
<h2 class="cufon">The User Interface</h2>
<p><div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/06/dwg_cad_cleaner.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/06/dwg_cad_cleaner.png&amp;h=233&amp;w=406&amp;zc=1" alt=""/></a><span class="caption"><br />
DWG CAD Cleaner Interface<br />
</span></div><br />
<br class="clear" /></p>
<h2 class="cufon">Part 1: Installation</h2>
<p>1. Download the script or copy the source code from below.<br />
2. Open 3DS Max/Design > Maxscript > Editor<br />
3. Press CTRL+N if the window is not blank and paste the code into the new window<br />
4. Press CTRL+S to save the file<br />
5. Press CTRL + E to execute the code, you will see the above dialog box<br />
<br class="clear" /></p>
<h2 class="cufon">Part 2: Usage</h2>
<p>There are only two checkboxes and both cannot be selected at the same time.</p>
<h4 class="cufon">Delete objects checkbox</h4>
<p> This will delete all objects that have been deemed unworthy and/or match the criteria of &#8220;garbage&#8221;</p>
<h4 class="cufon">Move to layer checkbox</h4>
<p> This will move all objects that have been deemed unworthy to a new layer called &#8220;To Delete&#8221;. Use this to review the objects that will be deleted before you delete them. Basically this is a safety net in case you don&#8217;t trust me OR some objects are being deleted by mistake. Trust me. <img src='http://www.davetyner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: jscript; light: true; title: ; notranslate">

	/* ########################################
	Version: v0.1
	DWG Garbage Scrubber; 
	modified/written by Dave Tyner (http://www.davetyner.com)
	Feel free to modify script functions for your needs. You can also expand the Script in any way you like,
	just please leave this original statement untouched.
	
	Copyright (C) 2013 Dave Tyner
	Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
	files (the &quot;Software&quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, 
	merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished 
	to do so, subject to the following conditions:
	The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
	THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
	TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
	##########################################	*/
		
try(destroyDialog Rollout001)catch() 

 Rollout Rollout001 &quot;Delete CAD Block Objects&quot; 
	 ( 
	 subrollout Subrollout001 &quot;Scrub CAD Blocks&quot; height:300 
	 ) 

	 Rollout Rollout002 &quot;Scrub CAD Blocks&quot; 
	 ( 
		 group &quot;Options&quot; 
		 ( 
			-- edittext txtEditText001 &quot;TextBox&quot; align:#left width:225 
			 --spinner spnSpinner001 &quot;Spinner&quot; range:[1,100,1] type:#integer align:#left width:50 
			 checkbox chkDelete &quot;Delete objects&quot; checked:true
			 checkbox chkMoveToLayer &quot;Move objects to new layer&quot;
			 button btnButton001 &quot;CLEAN&quot; 
			 label lblLabel001 align:#center 
			 progressbar doit_prog color:red 
		 ) 
		 
		on chkDelete changed state do
		(
			if not chkMoveToLayer.checked then chkMoveToLayer.checked= true else chkMoveToLayer.checked = false
		)
		
		on chkMoveToLayer changed state do
		(
			if not chkDelete.checked then chkDelete.checked = true else chkDelete.checked = false
		)
		
		 on btnButton001 pressed do 
			 (

					fn deleteObjectsFromLayer arr=(
						
						LayerManager.newLayerFromName &quot;To Delete&quot;
						for a in arr do (layermanager.getlayer (layermanager.count-1)).addnode a
							
					)	
					
					startobjects = objects.count
					thedel=#()
				 
						objs = for o in geometry collect o
						
						lblLabel001.text = &quot;Processing &quot; + objs.count as string + &quot; objects in scene&quot;
						
						if objs.count&gt;0 then
						(					
								for i = 1 to objs.count do  -- iterate through all geometry in the scene 
								(
								objs[i].controller=prs() --set the objects controller to Position/Rotation/Scale
									
								if objs[i].parent != undefined then objs[i].parent = undefined
								doit_prog.value = 100.*i/objs.count	
								)
										
									for sp in objects where classof sp == splineshape do append thedel sp --delete splines
									for o in geometry where classof o == LinkComposite do converttomesh o --convert BLOCKS to meshes
									for o in geometry where classof o == LinkComposite do append thedel o --Delete Block objects (non geometry, viewport killer)
									for o in objects where classof o == NURBSCurveshape do append thedel o --Delete Curve shapes if they exist
						)

						if chkMoveToLayer.checked == true then deleteObjectsFromLayer thedel			
						count = thedel.count
						if chkDelete.checked == true then delete thedel
						lblLabel001.text = (count as string) + &quot; objects have been modified&quot;
			 ) 

	 ) 
	 createdialog Rollout001 400 200 

	 addsubrollout Rollout001.Subrollout001 Rollout002 rolledup:false
	 
	 


</pre>
<p><br class="clear" /></p>
<h2 class="cufon">Example scene: Before and After</h2>
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/06/highPolyDWG.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/06/highPolyDWG.png&amp;h=233&amp;w=406&amp;zc=1" alt=""/></a><span class="caption">Before (Don&#8217;t believe the FPS, it is much SLOWER than this)</span></div>
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/06/lowPolyDWG.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/06/lowPolyDWG.png&amp;h=233&amp;w=406&amp;zc=1" alt=""/></a><span class="caption">After (Don&#8217;t believe the FPS, it is much FASTER than this)</span></div>
<p><div class="frame_left"><img src="" alt=""/><span class="caption"><br />
<h2 class="cufon"><a href="https://dl.dropboxusercontent.com/u/1292183/Polyform%20DWG%20Cleaner.ms">DOWNLOAD SCRIPT</a></h2>
<p></span></div><br />
<br class="clear" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/06/improve-viewport-performance-with-the-dwg-to-3ds-max-block-cleaner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SmartPLANT Review .NET API Usage Tutorial</title>
		<link>http://www.davetyner.com/2013/04/smartplant-review-net-api-usage-tutorial/</link>
		<comments>http://www.davetyner.com/2013/04/smartplant-review-net-api-usage-tutorial/#comments</comments>
		<pubDate>Fri, 05 Apr 2013 16:02:52 +0000</pubDate>
		<dc:creator>Parrish Husband</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Smartplant]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[customize]]></category>
		<category><![CDATA[Drapix]]></category>
		<category><![CDATA[intergraph]]></category>
		<category><![CDATA[parrish-husband]]></category>
		<category><![CDATA[plant]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[smart]]></category>
		<category><![CDATA[Smartpl]]></category>
		<category><![CDATA[VaxCtrl3]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=2228</guid>
		<description><![CDATA[SmartPlant Review .NET API Usage Tutorial By Parrish Husband When I worked as a piping designer, the SmartPlant Review driving and reporting fell into my lap more times than I can remember. Eventually I got to a point where I spent more time setting up VUE sessions and making tag reports than I was designing; [...]]]></description>
			<content:encoded><![CDATA[<h2 class="cufon">SmartPlant Review<br />
.NET API Usage Tutorial</h2>
<h4 class="cufon">By Parrish Husband</h4>
<p><br class="clear" /></p>
<p>When I worked as a piping designer, the SmartPlant Review driving and reporting fell into my lap more times than I can remember.  Eventually I got to a point where I spent more time setting up VUE sessions and making tag reports than I was designing; thus it became clear to me I would need to figure out a way to streamline my efforts.
</p>
<p>I was introduced to the SmartPlant Review API module shortly thereafter by one of our PDS administrators, and immediately began testing it&#8217;s capabilities and limitations.  One thing I struggled with initially was the steep learning curve to get started with the API in .NET.  Luckily the Drapix_API.chm file had some VB6 implementation examples, however the documentation felt more cryptic at times than it was informative.  I widened my search online and to my surprise came up with a series of empty Google results.
</p>
<p>For the next several months I tested the classes and methods inside the VaxCtrl3.dll until eventually getting to a point where I felt comfortable using it.  Having had my development progress slowed by the lack of information, I felt it was my responsibility to share what I had learned; so that hopefully others could benefit.  The idea behind this tutorial series is to de-mystify SmartPlant Review programming, and kick off healthy discussions on implementing ideas and techniques.  Therefore without further delay, welcome to part 1 of this development series.
</p>
<h2 class="cufon">Part 1: Setting up a new project in Visual Studio</h2>
<p><br class="clear" /><br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/1-NewVSProject.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/1-NewVSProject.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
1. Launch Visual Studio and start a new project<br />
<br class="clear" /><br />
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/2-NewCForm.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/2-NewCForm.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
2a. Create a new form application in the desired language format. The image on the left is setting up a new form project in C#.<br />
<br class="clear" /><br />
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/3-NewVBForm.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/3-NewVBForm.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
2b. For all the VB junkies out there, here is the VB.NET equivalent.<br />
<br class="clear" /><br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/4-AddReference.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/4-AddReference.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
3a. Add a reference to VaxCtrl3.dll to your project (typically located in your SPR install folder) as outlined below.<br />
3b. Right-Click on your project in the solution explorer, and select “Add Reference” from the context menu.<br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/5-AddVaxReference.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/5-AddVaxReference.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
3c. A dialog box will appear for adding in a specific reference. Click on the “Browse” tab and navigate to the directory containing VaxCtrl3.dll<br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/6-VaxDetails.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/6-VaxDetails.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
3d. Select the VaxCtrl reference from the solution explorer, and modify the “Copy Local” setting to TRUE from the properties view. (If desired, in .NET 4.0 and higher this property can be set to false using Embed Interop Types)<br />
<br class="clear" /><br />
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/7-ViewFormCode.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/7-ViewFormCode.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
4. Open the application form code editing page by right-clicking on the form on the project explorer and selecting “View Code” from the context menu.<br />
<br class="clear" /><br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/8-AddVaxNamespace.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/8-AddVaxNamespace.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
5. Add in the VaxCtrl3 reference namespace to the form code page. This strips away the requirement for needing to prefix objects inside the reference with the full reference name. In VB.NET the &#8220;Imports&#8221; keyword is used altenatively to &#8220;using&#8221;.<br />
<br class="clear" /><br />
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/10a-Add-Button.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/10a-Add-Button.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
6a. With the form designer active, add a button to the application form from the Visual Studio form toolbox.<br />
<br class="clear" /><br />
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/10-AddConnectButton.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/10-AddConnectButton.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
6b. With the new button selected, rename the button and change the button display text as desired from the properties window. It&#8217;s a good habit to get into managing control names yourselft, as it will make the project easier to read and edit.<br />
<br class="clear" /><br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/11-AddConnectClickMethod.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/11-AddConnectClickMethod.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
7. Create a new button click event method by double-clicking the button from the form designer. In C#, this is what gets generated:<br />
<br class="clear" /><br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/12-AddConnectClickMethodVB.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/12-AddConnectClickMethodVB.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
Alternately in VB.NET you get a subroutine in this format:</p>
<h4 class="cufon">*Note*</h4>
<p>Double clicking the button to create the event method allows Visual Studio to do some work in the background. In C#, the event is manually created in the button declaration of the Designer.cs page of the form. This can be done manually like this in C#:</p>
<pre class="brush: csharp; light: true; title: ; notranslate">
btn_SprConnect.Click += btn_SprConnect_Click;
</pre>
<p>In VB.NET similar changes are made in the background, but rather than link an event (which the “Handles” declaration does by itself) it simply adds a “WithEvents” flag to the button declaration in the Designer.vb page:</p>
<pre class="brush: vb; light: true; title: ; notranslate">

Friend WithEvents btn_SprConnect As System.Windows.Forms.Button

</pre>
<p><br class="clear" /><br />
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/13-SendHelloWorld.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/13-SendHelloWorld.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
8. Add in a method to send text to the SmartPlant Review text window. This is the C# code:<br />
<br class="clear" /><br />
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/14-SendHelloWorldVB.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/12-AddConnectClickMethodVB.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
&#8230;and the VB.NET equivalent<br />
<br class="clear" /><br />
The first line in the method simply creates a new instance of the DrApi class. This class represents the main SPR application when using the VaxCtrl3 API. Note that creating a DrApi object does not invoke a new instance of SmartPlant Review to be started. If an instance if SPR is running, the class constructor (new DrAPI() ) will latch onto the existing session, however it is otherwise separate from spr.exe. If you want to launch a new running instance of spr.exe, you can do so using Process.Start, or from the API itself with the “SessionAttach” method:<br />
C#:</p>
<pre class="brush: csharp; light: true; title: ; notranslate">
sprApp.SessionAttach(&quot;C:\\ProjectPath\\ProjectName.vue&quot;);
</pre>
<p>VB.NET:</p>
<pre class="brush: vb; light: true; title: ; notranslate">
sprApp.SessionAttach(&quot;C:\ProjectPath\ProjectName.vue&quot;)
</pre>
<p>The second portion of our new method simply checks to see if our DrApi object is set to something. If it’s not, this indicates the reference may not be resolving at runtime, or the VaxCtrl3.dll library is not properly registered.</p>
<p>Once we determine we indeed have a DrApi object, we send a message to the Text Window of the running SmartPlant Review application using the “TextWindow” method. As indicated in the Drapix_API.chm help file, the TextWindow method requires 4 parameters when invoking it:</p>
<p>1. Flags – Integer. A bit-mask controlling the display of the text window.<br />
2. Title – String. The text to be displayed as the Text Window title.<br />
3. Text – String. The text to be displayed in the Text Window.<br />
4. CharacterPosition – Integer. Controls the cursor position in the text window.</p>
<p>For the flags parameter, we can use the built-in constants from inside the referenced library (DrConstants), or the actual values themselves. In our example, I’ve used the actual constants, as it makes the method call easily identifiable without requiring additional commenting to clarify. However for reference, DrConstants.DR_TEXT_WIN_CLR is a value of 1.</p>
<p>Now that our method is complete, we can run our test project. Make sure an instance of SPR is running, otherwise the application will have no effect. If we were testing the result of the TextWindow method (which returns an integer value on error, zero on success) we’d find that without having an SPR instance running, we’d get a result of 1 (DR_NO_DR_AVAIL).<br />
This can be set up in the project as follows:</p>
<p>C#:</p>
<pre class="brush: csharp; light: true; title: ; notranslate">
int sprResult;

// Clear the text window and add the new output message
sprResult = sprApp.TextWindow((int)DrConstants.DR_TEXT_WIN_CLR, &quot;SPR Tutorial&quot;, &quot;Hello World&quot;, 0);

// Show a connection error if applicable
if (sprResult == 1) MessageBox.Show(&quot;Not connected to SmartPlant Review&quot;);

//
</pre>
<p>VB.NET:</p>
<pre class="brush: vb; light: true; title: ; notranslate">

Dim sprResult As Integer

' Clear the text window and add the new output message
sprResult = sprApp.TextWindow(DrConstants.DR_TEXT_WIN_CLR, &quot;SPR Tutorial&quot;, &quot;Hello World!&quot;, 0)

' Show a connection error if applicable
 If sprResult = 1 Then MessageBox.Show(&quot;Not connected to SmartPlant Review&quot;)

'
</pre>
<p><div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/15-HelloWorld.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/15-HelloWorld.png&amp;h=80&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
Here is the result of our application’s TextWindow method invoke:<br />
<br class="clear" /><br />
9. Output application information to the TextWindow using the concepts discussed above. Now that we have a way of communicating with SPR, we can send some useful information to the text window using a range of methods available to the DrApi class:</p>
<p><strong>Version</strong>(reference string) – Passes a string of the current application version to a referenced string object.<br />
<strong>GlobalOptionsSet</strong>(integer, double) – Passes a new value to an application constant. Used to control how the application and API methods behave globally.<br />
<strong>FileNameFromNumber</strong>(integer, reference string) – Passes a string of the nth file number in the active session to a referenced string object.<br />
<strong>FilePathFromNumber</strong>(integer , reference string) – Passes a string of the nth file number’s path in the active session to a referenced string object.<br />
<strong>TagNextNumber</strong>(out integer, integer) – Returns an integer value of the next available tag number to a defined integer. This is the value contained in the MDB site_table “next_tag_id” column.</p>
<p>C#:</p>
<pre class="brush: csharp; title: ; notranslate">
private void btn_SprConnect_Click(object sender, EventArgs e)
{
    // Create a new SPR Application object
    var sprApp = new DrApi();

    // Check if the application object is not null
    if (sprApp != null)
    {
        // Create output variables
        var sprVersion = string.Empty;
        var sprVueName = string.Empty;
        var sprMdbPath = string.Empty;
        var sprWorkDir = string.Empty;
        int sprNextTag;

        // Get the current SPR version
        sprApp.Version(ref sprVersion);

        // Turn the global file info variable on
        sprApp.GlobalOptionsSet((int)DrConstants.DR_G_API_FILE_INFO_MODE, 1);

        // Get the VUE session name
        sprApp.FileNameFromNumber(0, ref sprVueName);

        // Get the Mdb name
        sprApp.FileNameFromNumber(1, ref sprMdbPath);

        // Get the working directory
        sprApp.FilePathFromNumber(1, ref sprWorkDir);

        // Build the full mdb path
        sprMdbPath = Path.Combine(sprWorkDir, sprMdbPath);

        // Reset the global file info variable
        sprApp.GlobalOptionsSet((int)DrConstants.DR_G_API_FILE_INFO_MODE, 0);

        // Get the next tag number
        sprApp.TagNextNumber(out sprNextTag, 0);

        // Create the output message
        var sb = new System.Text.StringBuilder();
        sb.AppendFormat(&quot;Version: {0}\n&quot;, sprVersion);
        sb.AppendFormat(&quot;Vue Name: {0}\n&quot;, sprVueName);
        sb.AppendFormat(&quot;Mdb Path: {0}\n&quot;, sprMdbPath);
        sb.AppendFormat(&quot;Next Tag Number: {0}\n&quot;, sprNextTag);

        // Clear the text window and add the new output message
        sprApp.TextWindow((int)DrConstants.DR_TEXT_WIN_CLR, &quot;SPR Tutorial&quot;, sb.ToString(), 0);
    }
}
//
</pre>
<p>VB.NET:</p>
<pre class="brush: vb; title: ; notranslate">
Private Sub btn_SprConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_SprConnect.Click

    ' Create a new Spr application object
    Dim sprApp = New DrApi()

    ' Check if the application object is not null
    If sprApp IsNot Nothing Then

        ' Create output variables
        Dim sprVersion = String.Empty
        Dim sprVueName = String.Empty
        Dim sprMdbPath = String.Empty
        Dim sprWorkDir = String.Empty
        Dim sprNextTag As Integer

        ' Get the current SPR version
        sprApp.Version(sprVersion)

        ' Turn the global file info variable on
        sprApp.GlobalOptionsSet(DrConstants.DR_G_API_FILE_INFO_MODE, 1)

        ' Get the VUE session name
        sprApp.FileNameFromNumber(0, sprVueName)

        ' Get the MDB name
        sprApp.FileNameFromNumber(1, sprMdbPath)

        ' Get the working directory
        sprApp.FilePathFromNumber(1, sprWorkDir)

        ' Build the full mdb path
        sprMdbPath = Path.Combine(sprWorkDir, sprMdbPath)

        ' Reset the global file info variable
        sprApp.GlobalOptionsSet(DrConstants.DR_G_API_FILE_INFO_MODE, 0)

        ' Get the next tag number
        sprApp.TagNextNumber(sprNextTag, 0)

        ' Create the output message
        Dim sb = New StringBuilder()
        sb.AppendFormat(&quot;Version: {0}&quot; &amp; vbLf, sprVersion)
        sb.AppendFormat(&quot;Vue Name: {0}&quot; &amp; vbLf, sprVueName)
        sb.AppendFormat(&quot;Mdb Path: {0}&quot; &amp; vbLf, sprMdbPath)
        sb.AppendFormat(&quot;Next Tag Number: {0}&quot; &amp; vbLf, sprNextTag)

        ' Clear the text window and add the new output message
        sprApp.TextWindow(DrConstants.DR_TEXT_WIN_CLR, &quot;SPR Tutorial&quot;, sb.ToString(), 0)

    End If
End Sub
'
</pre>
<h4 class="cufon">*Note*</h4>
<p>In the two examples above, we declare variables beforehand, and then run the different methods required to obtain the SPR information. The GlobalOptionsSet method is used to set the file info mode (47) to on, so that the session files (vue/dri/mdb) are returned for the FileNameFromNumber and FilePathFromNumber methods rather than the .dgn files used to create the vue or dri. The vue/dri file number is 0, and the mdb number is 1.</p>
<p>Also note that rather than use string + append methods to build the output, a stringbuilder was used. I did this primarily because it’s a class better-suited for concatenating strings, and it also has a built-in formatting option for passing variable values (denoted with curl brackets surrounding the parameter number). This is identical to the string.Format() method in implementation.</p>
<p><br class="clear" /><br />
<div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2013/04/16-SprDetails1.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/04/16-SprDetails.png&amp;h=160&amp;w=300&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div><br />
Here is the resulting output from the implemented methods above:<br />
<br class="clear" /><br />
10. Using the <a href="https://github.com/Allockse/SharpPlant">SharpPlant</a> API wrapper, the same results can be achieved using minimal code:</p>
<p>C#:</p>
<pre class="brush: csharp; title: ; notranslate">
private void btn_SprConnect_Click(object sender, EventArgs e)
{
    // Create a new SprApplication object
    var sprApp = new SprApplication();

    // Check that the application is connected
    if (sprApp.IsConnected)
    {
        // Build the message string
        var sb = new StringBuilder();
        sb.AppendFormat(&quot;Version : {0}\n&quot;, sprApp.Version);
        sb.AppendFormat(&quot;Vue name: {0}\n&quot;, sprApp.SessionName);
        sb.AppendFormat(&quot;Mdb path: {0}\n&quot;, sprApp.MdbPath);
        sb.AppendFormat(&quot;Next Tag Number: {0}\n&quot;, sprApp.NextTag);

        // Send the message text to the SprApplication text window
        sprApp.TextWindow_Update(sb.ToString(), &quot;Spr Tutorial&quot;);
    }
}
</pre>
<p>VB.NET:</p>
<pre class="brush: vb; title: ; notranslate">
Private Sub btn_SprConnect_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_SprConnect.Click

    ' Create a new SprApplication object
    Dim sprApp = New SprApplication()

    ' Check that the application is connected
    If sprApp.IsConnected Then

        ' Build the message string
        Dim sb = New StringBuilder()
        sb.AppendFormat(&quot;Version : {0}&quot; &amp; vbLf, sprApp.Version)
        sb.AppendFormat(&quot;Vue name: {0}&quot; &amp; vbLf, sprApp.SessionName)
        sb.AppendFormat(&quot;Mdb path: {0}&quot; &amp; vbLf, sprApp.MdbPath)
        sb.AppendFormat(&quot;Next Tag Number: {0}&quot; &amp; vbLf, sprApp.NextTag)

        ' Send the message text to the SprApplication text window
        sprApp.TextWindow_Update(sb.ToString(), &quot;Spr Tutorial&quot;)
    End If
End Sub
'
</pre>
<h3 class="cufon"><a href="https://dl.dropbox.com/u/1292183/SprTutorial1_Source.zip">Download the source!</a></h3>
<p>In closing I&#8217;d like to personally thank Dave Tyner for having the infrastructure in place for hosting this information, as well as personally inviting me to share this knowledge.  I am confident that through our collaborative efforts the entire community stands to benefit.  I welcome any questions and feedback, as well as what you&#8217;d like to see in the next tutorial.  Also if you see something in my code that can be improved on, never hesitate to point it out; I will be most appreciative.  Until next time, happy coding.   </p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/04/smartplant-review-net-api-usage-tutorial/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Polyform Importer: The DWG batch importer for 3ds Max and 3ds Max Design</title>
		<link>http://www.davetyner.com/2013/03/polyform-importer-the-dwg-batch-importer-for-3ds-max-and-3ds-max-design/</link>
		<comments>http://www.davetyner.com/2013/03/polyform-importer-the-dwg-batch-importer-for-3ds-max-and-3ds-max-design/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 15:47:43 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[AutoCAD Plant 3D]]></category>
		<category><![CDATA[Autodesk 3DS Max]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[3DS max]]></category>
		<category><![CDATA[Autocad]]></category>
		<category><![CDATA[autodesk]]></category>
		<category><![CDATA[batch import]]></category>
		<category><![CDATA[dwg]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[plant 3d]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=2172</guid>
		<description><![CDATA[I recently released my dwg batch import utility for 3ds Max Design called &#8220;Polyform Importer&#8221;. The purpose for creating the utility was to solve the problem of only being able to import one file at a time into 3ds Max. I will show you how to install it and then talk about how it works. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently released my dwg batch import utility for 3ds Max Design called &#8220;Polyform Importer&#8221;. The purpose for creating the utility was to solve the problem of only being able to import one file at a time into 3ds Max. I will show you how to install it and then talk about how it works.</p>
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/03/SNAG-0052.jpg" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/03/SNAG-0052.jpg&amp;h=540&amp;w=320&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div>
<h2 class="cufon"><a href="">Installing the Polyform Importer</a></h2>
<p>1.	Navigate to the folder that you exported the project DWG files to<br />
2.	Download the <a href="https://www.dropbox.com/s/rrlc9x88v16s9ou/Polyform%20Importer.ms" target="_blank">Polyform Importer.ms</a> script and drop it into any 3ds Max Design scene<br />
3.	From the main menu click <strong>Customize</strong> then click <strong>Customize User Interface</strong><br />
4.	Click on the <strong>Menus</strong> tab<br />
5.	Click New&#8230; To create a new menu and name it <strong>Polyform Tools</strong><br />
6.	In the Menus list on the left bottom section find <strong>Polyform Tools</strong> and drag it over to the main menu list on the left just after <strong>MAXScript </strong><br />
7.	In your menus list click the + to expand the <strong>PolyformTools</strong> menu<br />
8.	In the <strong>Category</strong> drop-down list navigate to <strong>PolyformTools</strong><br />
9.	Click and drag <strong>Polyform Importer</strong> underneath your new Polyform Tools menu in the menus list<br />
10.	Close the <strong>Customize User Interface</strong> window<br />
11.	You should now see the Polyform Tools menu option<br />
12.	If you&#8217;re not seeing the importer, go back through the steps and find where you may have made an error</p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=Bw_In-pEnS8">Installing and Using the Polyform Importer Video</a></h2>
<p>For those of us who need to SEE it done, there is also this video. If YouTube is blocked at your work, try <a href="http://www.davetyner.com/2011/08/youtube-is-blocked-at-your-work-heres-the-fix/">this</a></p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/Bw_In-pEnS8?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="">The Code</a></h2>
<p>For you code geeks out there, here is the source. Feel free to modify or try stuff. If you make something cool with it, please share! It will only help make everyone better.</p>
<h4 class="cufon">UI Element Setup&#8230;</h4>
<p><code><br />
global dwgList --global variable needed for name collection<br />
global importDrawingPath --global variable for path to imports<br />
--<br />
macroScript Polyform_Importer category: "PolyFormTools"<br />
(<br />
	Rollout ImportExport "Import/Export"<br />
(<br />
	group "Directory and files"<br />
		(<br />
			edittext txt_dir "Directory" align:#left across:2 width:225<br />
			button btn_browse "..." align:#right width:20<br />
			edittext txt_pre "Prefix:" text:"" tooltip:"Put your file prefix here" align:#left width:105 across:2<br />
			button btnUpdate "Update" enabled:false<br />
			edittext txt_ext "Extension" text:"dwg" align:#left width:105<br />
			--edittext txt_suf "Sufffix: *" text:"" tooltip:"Put your suffix here" align:#left width:105<br />
			label lblNumFiles "No files selected"<br />
		)<br />
	group "Import Options"<br />
		(<br />
			checkbox chkFLM "Link File"<br />
			checkbox chkIMP "Import" checked:true<br />
			checkbox chkCreateMaxFile "Save import as .Max file" across:2<br />
			checkbox chkMergeXrefs "Merge Xrefs" enabled:false align:#right<br />
			checkbox chk_prefixmodelname "File Name Prefix" tooltip:"This will prefix each object with the file that it came from" align:#left --offset:[-45,0]<br />
			checkbox chkSmooth "Smooth Modifier" across:2 enabled:false<br />
			edittext txt_NoSmoothType text:"beam,stair,steel" width:75 tooltip:"Do not apply smooth modifier to files with this prefix"<br />
			checkbox chk_unparent "Unparent Objects" align:#left checked:true<br />
			label lbl_status "Ready"<br />
		)<br />
		group "Do it!"<br />
		(<br />
			button btn_Import "GO" width:75 height:40<br />
		)<br />
</code><br />
<br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">When I check a box or press a button do something</h4>
<p><code><br />
		on chkFLM changed state do<br />
		(<br />
			chkIMP.checked = false<br />
		)<br />
		on chkIMP changed state do<br />
		(<br />
			chkFLM.checked = false<br />
		)<br />
</code><br />
We can&#8217;t Import AND use the File Link Manager. If we check one, we will uncheck the other.<br />
<br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">Toggle Checkbox when other Checkbox gets Checked</h4>
<p><code><br />
		on chkCreateMaxFile changed state do<br />
		(<br />
			if not chkMergeXrefs.enabled then chkMergeXrefs.enabled = true else chkMergeXrefs.enabled = false --Allockse from the forum suggested I modify this. Have not done it yet but I will!<br />
		)<br />
		on chk_prefixmodelname changed state do<br />
		(<br />
			if not chkSmooth.enabled then chkSmooth.enabled = true else chkSmooth.enabled = false<br />
		)<br />
</code><br />
Same idea behind then Prefix Model Name. If we check it, the Smooth checkbox enabled property is toggled. Why? Because we need the file name to apply the smooth modifier<br />
<br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">Setting import directory, tell us how many files will be imported</h4>
<p><code><br />
		on btn_browse pressed do<br />
		(<br />
			local fpath = getSavePath initialDir:@"F:\Projects\Autodesk\Technical Conference\dataset" caption:"Select any file in the source directory:"<br />
			--shellLaunch "explorer.exe" (getdir #scene)<br />
			if fpath != undefined then<br />
			(<br />
			local extension = txt_ext.text<br />
			local pfix = if txt_pre.text == "" then pfix = "*" else pfix = txt_pre.text<br />
			local thepath = fpath + "\\" +  pfix + "." + extension<br />
			local dcount = (for f in getfiles (thepath) collect f).count<br />
			if dcount > 0 then<br />
				(<br />
					lblNumFiles.text = dcount as string + " files will be imported"<br />
					importDrawingPath = fpath + "\\" + pfix + "." + extension<br />
					txt_dir.text = fpath<br />
				)<br />
			)<br />
			btnUpdate.enabled = true<br />
		)<br />
</code><br />
When the user pressed the browse button the code checks to see how many dwg&#8217;s are in the directory and displays that on the label. After the directory is set, the update button is enabled.<br />
<br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">Update the imported drawing count</h4>
<p><code><br />
		on btnUpdate pressed do<br />
		(<br />
			local pfix = if txt_pre.text == "" then pfix = "*" else pfix = txt_pre.text<br />
			local thepath = (getfilenamepath importDrawingPath) +  pfix + "." + txt_ext.text<br />
			importDrawingPath = thePath<br />
			local dcount = (for f in getfiles (thepath) collect f).count<br />
						if dcount > 0 then<br />
									(<br />
										lblNumFiles.text = dcount as string + " files will be imported"<br />
										--txt_dir.text = thepath<br />
									) else (<br />
										lblNumFiles.text = "No files will be imported"<br />
									)<br />
		)<br />
</code><br />
When the user changes the value in the prefix text box to *PIP* or something like that, the resulting import number will be filtered down to all drawings that contain the letters PIP in the drawing name. This is NOT case sensitive.<br />
<br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="">GO Button pressed! Work your magic computer!</a></h2>
<h4 class="cufon">Write results to log file function</h4>
<p><code><br />
		on btn_Import pressed do<br />
		(<br />
			fn writetolog dir larr fileLog=<br />
						(<br />
									local t = localtime<br />
									local exportlog = openfile fileLog mode:"a"<br />
									format "%\n" t to:exportlog<br />
									for i = 1 to larr.count do format "% % seconds\n" larr[i][1] larr[i][2] to:exportlog<br />
									format "<--##############################-->\n" to:exportlog<br />
									close exportlog<br />
						)<br />
</code><br />
During the import process, we are collecting data into an array. At the end we write to a text file that will be located in the same directory as the drawings.<br />
<br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">Xref the DWG&#8217;s into a single drawing and merge them (if you want)</h4>
<p><code><br />
			fn xrefobjs dirname mergebool =<br />
						(<br />
										resetmaxfile #noprompt<br />
										for f in (getFiles (dirName+"\\*.max")) do<br />
										 (<br />
											mf = xrefs.addNewXrefFile f<br />
											if mergebool then merge mf<br />
										 )<br />
						)<br />
</code><br />
If the Save import as .Max file option is checked, all of the imported drawings will be referenced into a new drawing at the end. This allows you to get a quick visual on the imported drawings. You can discard this file if you choose. It won&#8217;t affect the other drawings.<br />
<br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">IMPORTING WAS HERE</h4>
<p><code><br />
			fn importObjects filename nsmooth sm=<br />
						(<br />
										local impobjs = for o in objects where o.isfrozen == false collect o<br />
										for obj in impobjs where classof obj == Editable_mesh do obj.name = (substring obj.name (6+1) obj.name.count)<br />
										for obj in impobjs where classof obj == Editable_mesh  do obj.name = (filename + "_" + obj.name)<br />
										local smootharr = #()<br />
										if chkSmooth.checked == true then<br />
											(<br />
														for ns = 1 to nsmooth.count do<br />
														(<br />
															local cfilter = "*" + nsmooth[ns] + "*" -- ("*" + nsmooth[ns] + "*")<br />
																	for imp = impobjs.count to 1 by -1 where matchpattern impobjs[imp].name pattern:cfilter == true do<br />
																	(<br />
																			deleteitem impobjs imp<br />
																	)<br />
														)<br />
														if impobjs.count > 0 then for i = 1 to impobjs.count where impobjs[i].modifiers.count == 0 do addmodifier impobjs sm<br />
											)<br />
											local impobjs = for o in objects where o.isfrozen == false do freeze o<br />
						)<br />
</code><br />
This is the meat of the import process where we </p>
<ul>
<li>Rename objects to the-file-they-came-from_the-layer-they-are-on</li>
<li>Apply smooth modifier to any object that does not contain the characters in the do-no-smooth-if text box</li>
<li>Freeze the imported objects</li>
</ul>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">Clean this mess up!</h4>
<p><code><br />
			fn unparent =<br />
						(<br />
														startobjects = objects.count<br />
														thedel=#()<br />
														for o in geometry do (<br />
														o.controller=prs()<br />
														if classof o.parent == LinkComposite then<br />
														(<br />
															o.parent = undefined<br />
														) else (<br />
															o.parent = undefined<br />
														)<br />
														)<br />
															for sp in objects where classof sp == splineshape do append thedel sp<br />
															for o in geometry where classof o == LinkComposite do converttomesh o --append thedel o<br />
															for o in geometry where classof o == LinkComposite do append thedel o<br />
															for o in objects where classof o == NURBSCurveshape do append thedel o<br />
--<br />
															local count = thedel.count<br />
															delete thedel<br />
															count<br />
						)<br />
</code><br />
This function deals with the cleanup and runs when the Unparent checkbox is checked. Make sure you do this.</p>
<ul>
<li>Unparent everything</li>
<li>Convert any block objects to meshes</li>
<li>Delete Block objects, Splines, and NURBS curves</li>
</ul>
<p>If you find that this part is breaking your model. Please <a href="http://www.davetyner.com/contact-us/" target="_blank">contact me</a>. It would also help to send your model that is breaking it.</p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h4 class="cufon">The rest of it</h4>
<p><code><br />
			local startimp=timestamp()<br />
			local theobj = #()<br />
			local thedwg = #()<br />
			local s = smooth()<br />
			local noSmooth = filterstring txt_NoSmoothType.text ","<br />
			s.autosmooth=true<br />
			clearlistener()<br />
			disablesceneredraw()<br />
			local exportfilelog = txt_dir.text + "\\importlog.txt"<br />
			local importFileList = txt_dir.text + "\\importFileList.txt"<br />
			if doesFileExist exportfilelog == false then<br />
				(<br />
					cf = createFile exportfilelog<br />
					close cf<br />
				)<br />
						for f in getfiles (importDrawingPath) do append thedwg f<br />
						for tf = 1 to thedwg.count do<br />
									(<br />
										local logarr = #()<br />
										local mfn = getfilenamefile thedwg[tf]<br />
										local startIntTime = timestamp()<br />
												local filename = filenameFromPath thedwg[tf]<br />
												if chkFLM.checked then<br />
												(<br />
													filelinkmgr.attach thedwg[tf]<br />
												) else (<br />
															if chkCreateMaxFile.checked == true then<br />
															(<br />
																					resetmaxfile #noprompt<br />
																					savefile = txt_dir.text + "\\" + mfn + ".max" --@"C:\Dropbox\projects\iso15926\Plant3D Sample\exported acad file\" + mfn + ".max"<br />
																					if tf != 1 then importFile thedwg[tf] #noprompt else importFile thedwg[tf]<br />
																					append logarr #("File saved successfully: ", savefile)<br />
															)	else (<br />
																					if tf != 1 then importFile thedwg[tf] #noprompt else importFile thedwg[tf]<br />
																					append logarr #("File imported successfully: ", thedwg[tf])<br />
															)<br />
												)<br />
--<br />
--<br />
										if chk_unparent.checked == true then<br />
													(<br />
														local thecount = unparent()<br />
														lbl_Status.text = "Deleted " + thecount as string + " objects"<br />
													)<br />
										if chk_prefixmodelname.state == true then local impobjs = importObjects mfn nosmooth	s<br />
										if chkCreateMaxFile.checked == true then savemaxfile savefile<br />
--<br />
										local finIntTime = timestamp()<br />
--<br />
										local intTotal = ((finIntTime-startIntTime)/1000) as float<br />
										append logarr #("File Import Time: ", intTotal)<br />
										writetolog txt_dir.text logarr exportfilelog<br />
										format "imported % in %\n" filename intTotal<br />
									)<br />
--<br />
		local tend=timestamp()<br />
		local mbool = false<br />
		local intTotal = ((tend-startimp)/1000) as float<br />
		if chkMergeXrefs.checked == true then mbool = true<br />
		if chkCreateMaxFile.checked == true then xrefobjs txt_dir.text mbool<br />
		format "imported % files in %\n seconds" thedwg.count intTotal<br />
		lbl_Status.text = "Imported " + thedwg.count as string + " files in " + intTotal as string + " seconds"<br />
--<br />
		enablesceneredraw()<br />
--<br />
		)<br />
</code><br />
This is the main portion of the import where we are getting files, throwing them into functions and returning values, timestamping, writing to the log file.</p>
<p>If you need furthur clarity on some of this code. Again, don&#8217;t hesitate to <a href="http://www.davetyner.com/contact-us/" target="_blank">contact me</a>. I would love to hear you comments and/or suggestions for improvement. They tell me that I have to say you are using this code at your own risk and if something gets messed up as a result of your using it incorrectly, its on you. Fortunately, that is not likely to happen unless you alter the code somehow. <img src='http://www.davetyner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/03/polyform-importer-the-dwg-batch-importer-for-3ds-max-and-3ds-max-design/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AutoCAD Plant 3D to 3ds Max Design 2014 Workflow &#8211; 1080P HD Video Tutorial Series</title>
		<link>http://www.davetyner.com/2013/03/autocad-plant-3d-to-3ds-max-design-2014-1080p-hd-video-tutorial-series/</link>
		<comments>http://www.davetyner.com/2013/03/autocad-plant-3d-to-3ds-max-design-2014-1080p-hd-video-tutorial-series/#comments</comments>
		<pubDate>Wed, 27 Mar 2013 18:45:48 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[AutoCAD Plant 3D]]></category>
		<category><![CDATA[Autodesk 3DS Max]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[3ds Max Design 2014]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[file linking]]></category>
		<category><![CDATA[gas]]></category>
		<category><![CDATA[importing]]></category>
		<category><![CDATA[material]]></category>
		<category><![CDATA[oil]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[slate]]></category>
		<category><![CDATA[visualization]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=2121</guid>
		<description><![CDATA[I have released my video tutorial series for creating an animation in 3ds Max Design using AutoCAD Plant 3D Models. Although these tutorials were specifically written for using a specific data set, the concepts are applicable to any 3ds Max Design model. Export Plant 3D Model to Neutral DWG Part of my visualization for oil [...]]]></description>
			<content:encoded><![CDATA[<p>I have released my video tutorial series for creating an animation in 3ds Max Design using AutoCAD Plant 3D Models. Although these tutorials were specifically written for using a specific data set, the concepts are applicable to any 3ds Max Design model.</p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=elFeqlcJF9E" target="_blank">Export Plant 3D Model to Neutral DWG</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design 2014. In this episode, we will export our AutoCAD Plant 3D models to a dwg format that is importable by 3ds Max Design.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/elFeqlcJF9E?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=qVpQ3g7J7Z0" target="_blank">File Linking</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. This video talks about the 3ds Max Design File Link Manager.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/qVpQ3g7J7Z0?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=lLKWK-Dt-do" target="_blank">3ds Max Design 2014 Importing Function OOTB</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. This video talks about the 3ds Max Design out of the box import function.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/lLKWK-Dt-do?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=Bw_In-pEnS8" target="_blank">Polyform DWG Batch Importer for 3ds Max Design</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. This video walks you though installing and using my custom Polyform Importer script. The purpose of the script is to enable you to perform batch imports on your project files. Download the <a href="https://dl.dropbox.com/u/1292183/Polyform-Importer/Polyform-Importer.ms" target="_blank">Polyform Importer</a>. Install instructions are easy and explained at the beginning of the video.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/Bw_In-pEnS8?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=KBPiJ2SZKhU" target="_blank">Batch Importer Cleanup</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. In this video we look at what happens when you import a dwg model NOT created in Plant 3D and how the importer pretty much saves your life. Mostly, ish.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/KBPiJ2SZKhU?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=iHL-wl5d3tY" target="_blank">Creating a Daylight System in 3ds Max Design 2014</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. Time to shed some light on this model. In this video we quickly create a great looking outdoor lighting/environment solution.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/iHL-wl5d3tY?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=cma-KrKqlOc" target="_blank">Adjusting the Viewport Display Quality</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. In this video we adjust our viewport display options so that we can see changes made to our new lighting setup in real time.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/p9sSgQAZTK4?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>edit: displays now, thanks Adam!<br />
<br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=q9yY9czi9a8" target="_blank">Creating Materials with the Slate Material Editor</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. Now that we have our basic lighting setup, we are going to create some materials to make our project really shine! Pun intended.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/q9yY9czi9a8?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=d1p-4Ds7Zt8" target="_blank">Materials Application Workflow</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. Now that we have created an Arch &#038; Design material, it&#8217;s time to repeat the process for each type of object that needs a material. I speed up the workflow 5x but talk about each step along the way.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/d1p-4Ds7Zt8?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=kEPK4llpwOU" target="_blank">Basic Camera Animation in 3ds Max Design 2014</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. Now that we have our materials created, it&#8217;s time to start prepping for animation. Our first step will be to create a camera and animate its motion smoothly along a pre-defined path. </p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/kEPK4llpwOU?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<h2 class="cufon"><a href="http://www.youtube.com/watch?v=p9sSgQAZTK4" target="_blank">Create Fast Preview Animation in 3ds Max Design 2014</a></h2>
<p>Part of my visualization for oil and gas tutorial series on importing AutoCAD Plant 3D dwg&#8217;s to 3ds Max Design. Our camera is animated and we are ready to render, right? WRONG!! Rendering without creating a preview first is very risky. Although the 3ds Max Design Nitrous viewport is awesome, it cannot handle 2000 objects and a total scene size of 3M polygons @ 30 fps from the timeline. For that purpose, we will need to create a viewport animation sequence at a fraction of the final render time. This will ensure the final shot is timed properly and meets our expectations.</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/p9sSgQAZTK4?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p><br class="clear"/><br />
<br class="clear"/></p>
<p>OK, that wraps up this lesson! Of course this is just the start. As I explained in the video, many of the steps involved here have deeper &#8220;sub-steps&#8221;. My next video will look at rendering your final image or sequence. Hope you learned a lot or were able to at least re-familiarize yourself with the workflow. If you have questions, comments, critiques, or criticisms, feel free to leave them here, in the forum, or on any of the video comments on youtube. </p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/03/autocad-plant-3d-to-3ds-max-design-2014-1080p-hd-video-tutorial-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoCAD Plant 3D &#8211; Think of the Money You&#8217;ll Save!</title>
		<link>http://www.davetyner.com/2013/03/autocad-plant-3d-think-of-the-money-youll-save/</link>
		<comments>http://www.davetyner.com/2013/03/autocad-plant-3d-think-of-the-money-youll-save/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 15:47:23 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[AutoCAD Plant 3D]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Plant Software]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[3DS max]]></category>
		<category><![CDATA[Autocad]]></category>
		<category><![CDATA[plant 3d]]></category>
		<category><![CDATA[plant software]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=2101</guid>
		<description><![CDATA[The first in what will be a series of images I am creating to visualize the current plant software market. In this image, I am trying to show that Plant 3D has a &#8220;cool&#8221; factor that their competition cannot possible hope to compete with. More to come. Let me know what you think! Headphones model: [...]]]></description>
			<content:encoded><![CDATA[<p>The first in what will be a series of images I am creating to visualize the current plant software market. In this image, I am trying to show that Plant 3D has a &#8220;cool&#8221; factor that their competition cannot possible hope to compete with.</p>
<div class="frame_center"><a href="http://www.davetyner.com/wp-content/uploads/2013/03/Project-Yankee-Headphones.jpg" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/03/Project-Yankee-Headphones.jpg&amp;h=640&amp;w=250&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div>
<p>More to come. Let me know what you think!</p>
<p>Headphones model: <a href="http://sketchup.google.com/3dwarehouse/details?mid=937cdf200b33bdfd1aec2282dd8bc87a&#038;prevstart=0">Trimble Model Warehouse</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/03/autocad-plant-3d-think-of-the-money-youll-save/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Corona Alpha4 Renderer for 3DS Max</title>
		<link>http://www.davetyner.com/2013/03/corona-alpha4-renderer-for-3ds-max/</link>
		<comments>http://www.davetyner.com/2013/03/corona-alpha4-renderer-for-3ds-max/#comments</comments>
		<pubDate>Mon, 18 Mar 2013 15:32:49 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[3DS Max Plugins]]></category>
		<category><![CDATA[Autodesk 3DS Max]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[3DS max]]></category>
		<category><![CDATA[autodesk]]></category>
		<category><![CDATA[corona]]></category>
		<category><![CDATA[plant 3d]]></category>
		<category><![CDATA[render]]></category>
		<category><![CDATA[renderer]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=2072</guid>
		<description><![CDATA[I want to give everyone a heads up that there is a new rendering engine on the scene that looks very promising. It&#8217;s called the Corona renderer. It&#8217;s fast, flexible, very easy to use and best of all it&#8217;s free!! Time is money and we all have precious little of both. This bad boy will [...]]]></description>
			<content:encoded><![CDATA[<p>I want to give everyone a heads up that there is a new rendering engine on the scene that looks very promising. It&#8217;s called the Corona renderer. It&#8217;s fast, flexible, very easy to use and best of all it&#8217;s free!! Time is money and we all have precious little of both. This bad boy will make quick work of your scenes. The build is still in alpha but they&#8217;re making improvements and updating it all the time. It would definitely be worth a minute of your time. Head on over to their website to check it out after you check out a couple of the images I created using it below.</p>
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2012/12/corona-self-illumination-test.jpg" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2012/12/corona-self-illumination-test.jpg&amp;h=640&amp;w=250&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div>
<div class="frame_left"><a href="http://www.davetyner.com/wp-content/uploads/2013/03/greeble-corona-2m-comp.jpg" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/03/greeble-corona-2m-comp.jpg&amp;h=640&amp;w=250&amp;zc=1" alt=""/></a><span class="caption"><br />
</span></div>
<p></p>
<p>Website: <a href="http://corona-renderer.com/">http://corona-renderer.com/</a><br />
To download the renderer and benchmark scene or find reference documents, visit the <a href="http://corona-renderer.com/forum/index.php/topic,559.0.html">Corona Renderer Forums</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/03/corona-alpha4-renderer-for-3ds-max/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Invasion of the CAD Snatchers!</title>
		<link>http://www.davetyner.com/2013/03/invasion-of-the-cad-snatchers/</link>
		<comments>http://www.davetyner.com/2013/03/invasion-of-the-cad-snatchers/#comments</comments>
		<pubDate>Tue, 12 Mar 2013 16:40:22 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Editorial]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Plant Software]]></category>
		<category><![CDATA[autodesk]]></category>
		<category><![CDATA[bentley plant]]></category>
		<category><![CDATA[intergraph]]></category>
		<category><![CDATA[ISO15926]]></category>
		<category><![CDATA[openplant]]></category>
		<category><![CDATA[plant 3d]]></category>
		<category><![CDATA[Smartplant]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=2038</guid>
		<description><![CDATA[So I am sitting there working away in my little corner on Friday when all of a sudden, the live chat room became engulfed in the flame (pun intended?) of heated discussion that involved the Intergraph Marketing Machine, Bentley&#8217;s OpenPLANT, and how Autodesk&#8217;s Plant 3D product intends to dominate mid level market at a time [...]]]></description>
			<content:encoded><![CDATA[<p>So I am sitting there working away in my little corner on Friday when all of a sudden, <a href="http://www.davetyner.com/live/">the live chat room</a> became engulfed in the flame (pun intended?) of heated discussion that involved the Intergraph Marketing Machine, Bentley&#8217;s OpenPLANT, and how Autodesk&#8217;s Plant 3D product intends to dominate mid level market at a time that Owner Operators find themselves in dire need of a working solution. Read on, if you dare!</p>
<p>edit:<br />
mini translator:<br />
O/O = Owner Operator<br />
Ingr/IG = Intergraph<br />
P3D = Plant 3D<br />
SP = SmartPLANT<br />
OP = OpenPLANT<br />
CW = CADWorx</p>
<h6 class="cufon">
zortar	:  	CADWorx licenses = CADWorx licenses x 2 !!<br />
p-salad	:  	wOW!<br />
p-salad	:  	Why are y&#8217;all picking up CW? y&#8217;all using 2012 or 2013?<br />
zortar	:  	Apparently Intergraph is making inroads (Bentley joke) into the major O/O&#8217;s and they are requiring 3D CADWorx deliverables.<br />
zortar	:  	we are using 2012<br />
p-salad	:  	O/O&#8217;s?<br />
zortar	:  	The Owner/Operators are being told by Ingr that their CADWorx models will eventually work with their Smartplant Foundation<br />
p-salad	:  	AH<br />
zortar	:  	I don&#8217;t know but its a marketing effort that is working.  Bentley tried for years to accomplish this and Ingr is actually doing it.<br />
p-salad	:  	Who owns SP? I&#8217;m pretty ignorant about it<br />
zortar	:  	Intergraph<br />
zortar	:  	Same people that own CADWorx<br />
p-salad	:  	Ok<br />
zortar	:  	And the same people that own Leica (actually Hexagon owns them all)<br />
zortar	:  	So as far as &#8220;total enterprise solutions&#8221; go<br />
p-salad	:  	Hrmmm<br />
zortar	:  	but that&#8217;s only competition on the low end &#8211; Autodesk doesn&#8217;t have a data-centric offering.<br />
zortar	:  	See: from the O/O POV IG has both the large project data-centric and small-project solutions.<br />
zortar	:  	well<br />
zortar	:  	And Bentley wanted to &#8220;move&#8221; people from AutoPlant to OpenPlant.  Intergraph is saying: &#8220;you want both?  we like that and we have both&#8221;<br />
zortar	:  	With Bentley<br />
p-salad	:  	I didn&#8217;t see OP as a replacement<br />
p-salad	:  	It seemed to be a competitor for the big dogs<br />
zortar	:  	Exactly<br />
zortar	:  	*replacement<br />
p-salad	:  	ah<br />
<br />
<blockquote><br />
<h3 class="cufon">
I don&#8217;t know but its a marketing effort that is working.  Bentley tried for years to accomplish this and Ingr is actually doing it.<br />
</h3>
<p></blockquote><br />
zortar	:  	Because they were more interested in converting their user base than providing scalable solutions.<br />
zortar	:  	Which means a big fail in the eyes of the typical AutoCAD/AutoPlant user<br />
p-salad	:  	Bingo<br />
zortar	:  	How long Intergraph can keep CADWorx viable as their low-end solution may be a moot point if they convert the user base over quickly enough.<br />
zortar	:  	O/O&#8217;s may eventually see more value in maintaining their data in SP rather than being AutoCAD-compatible.<br />
p-salad	:  	but whats the cost of SP?<br />
zortar	:  	To large O/O&#8217;s the enterprise contracts are nomimal (i.e. not a per seat price) AND they get SP and CADWorx bundled for all their sites.<br />
zortar	:  	The SP cost per seat ($30k) precludes us from using it.  Also<br />
p-salad	:  	WOW 30K!? but thats a great deal with SP/CW bundled. Now the O/O do all their design work in house right?<br />
zortar	:  	that&#8217;s not a bundled per seat price: think BIG like &#8230;for example:  5000 users<br />
zortar	:  	you pay $10 million a year for an Intergraph enterprise license that includes ALL of their software.  That equates to $2000 per seat per year.<br />
zortar	:  	You get the picture<br />
m3	:  	how can you possibly derive &#8216;value&#8217; from those numbers<br />
zortar	:  	O/O IT decision makers aren&#8221;t the ones evaluating actual value<br />
zortar	:  	Just like replacing servers with cloud storage.  The &#8220;real&#8221; value is in cost savings and simplifying deployment.<br />
m3	:  	like<br />
<br />
<blockquote><br />
<h3 class="cufon">
the impact of a true datacentric design system should be carefully considered. It&#8217;s significant.<br />
</h3>
<p></blockquote><br />
m3	:  	its quantifying the unquantifiable.<br />
zortar	:  	Companies already have DBA&#8217;s and that infrastructure.  Example: hundreds of disparate purchasing systems have been replaced by SAP.<br />
m3	:  	they=?<br />
zortar	:  	Is this new megalithic monster better?  Corporations can have more control so they say &#8220;yes&#8221;.  The use just sits there and cusses at SAP.<br />
zortar	:  	*user<br />
zortar	:  	they=corporate IT<br />
zortar	:  	I&#8217;m trying to paint a picture of top-down decision making that satisfies the perceived need via a corporate business case.<br />
zortar	:  	Your mileage may vary&#8230;<br />
m3	:  	yeah. I know they have deebeeaeez but the impact of a true datacentric design system should be carefully considered. It&#8217;s significant<br />
zortar	:  	Another example: a small refinery<br />
zortar	:  	Corporation X&#8217;s IT dept. (in some other state) has a &#8220;menu&#8221; of software that they are allowed to install.  Intergraph solutions have replaced Bentley solutions.<br />
m3	:  	Ingr is the undisputed champion of the top down strategy!<br />
zortar	:  	That&#8217;s what I&#8217;m getting at.  The value is defined by people far removed from actual usage.<br />
zortar	:  	They hold the purse strings and can justify their decisions due to great marketing.<br />
zortar	:  	Didn&#8217;t mean to monopolize the chat&#8230;sorry<br />
jedi	:  	what a great read this has been. thx Zortar and PS<br />
zortar	:  	sure<br />
m3	:  	but in their defense, the product is as solid as a rock.<br />
m3	:  	the sales pitch just puts it over the top<br />
jedi	:  	Intergraph SP is the big boy right now. its the mid tier piping soluitons that are fair game.<br />
zortar	:  	And quelches objections from the users<br />
jedi	:  	if they pay for it<br />
zortar	:  	they don&#8217;t pay for it: they say if you want the work you play with our toys on your dime<br />
jedi	:  	really? thats a bit diff from here.<br />
jedi	:  	wait<br />
<br />
<blockquote><br />
<h3 class="cufon">
ingr&#8217;s strategy is to hit the O/O&#8217;s and force the change downstream<br />
</h3>
<p></blockquote><br />
zortar	:  	I&#8217;m seeing more and more of it.  That&#8217;s what disturbs me.  19 years with AutoPlant and not a single delivered intelligent model.<br />
m3	:  	OO<br />
zortar	:  	Ingr&#8217;s strategy may be to get clients to require CADWorx 3D models as deliverables because Intergraph has told them those models will be SmartPlant-compatible.<br />
zortar	:  	&#8230;someday<br />
m3	:  	ingr&#8217;s strategy is to hit the O/O&#8217;s and force the change downstream<br />
zortar	:  	zactly!<br />
m3	:  	which is brilliant<br />
zortar	:  	and painful<br />
m3	:  	*for them<br />
jedi	:  	Ok i see&#8230;.BASF<br />
zortar	:  	So the client thinks they&#8217;ve leveled the playing field for small EPCs like us by allowing us to use CADWorx instead of SmartPlant.<br />
zortar	:  	How am I to tell them: we don&#8217;t want to use CADWorx?  They would be like: okay.  See ya later!<br />
jedi	:  	when did Itngrpah start the cadworx to SP model conversion marketing?<br />
m3	:  	lol<br />
m3	:  	the day after they bought them<br />
jedi	:  	lol<br />
zortar	:  	I don&#8217;t know Jedi<br />
jedi	:  	seeing in believing<br />
zortar	:  	I agree with that Jedi.  However I have to respond and have no voice in the client&#8217;s decisions.<br />
m3	:  	it&#8217;s been that way for years. They are pretty open about it.<br />
zortar	:  	Neither do my local plants.  Those decisions are being made at a corporate level &#8211; not at the sites.<br />
zortar	:  	A corporation&#8217;s argument: before you were getting AutoCAD deliverables.  Now with CADWorx you are still getting AutoCAD deliverables&#8230;<br />
jedi	:  	ive just not seen first hand that marketing<br />
zortar	:  	&#8230;but now those deliverables will be SP-compatible if you require CADWorx.<br />
zortar	:  	I&#8217;ve only seen the results of it<br />
zortar	:  	A local EPC just dropped AutoPlant and went with Intergraph-only software. This means in order to compete, their competitors must follow the same path.<br />
zortar	:  	Which means: CADWorx and Smartplant.  A fit for all project sizes.<br />
zortar	:  	So<br />
zortar	:  	Which leaves me &#8230; out of key!<br />
tkm	:  	GM guys<br />
m3	:  	z<br />
m3	:  	are you saying that war is unwinnable?<br />
m3	:  	its a very interesting and comment worthy topic<br />
m3	:  	how can P3D beat that strategy.<br />
tkm	:  	I am hearing smart plant a lot<br />
m3	:  	AFAIK P3D is taking the ground up approach.<br />
zortar	:  	Yes<br />
m3	:  	The fact that schools are standardizing around Plant 3D is their ace in the hole.<br />
m3	:  	But that is a long term investment<br />
zortar	:  	well<br />
tkm	:  	wow<br />
zortar	:  	what they thought was an educational grant was only good for one year.  I have egg on my face and am trying to salvage it.<br />
m3	:  	i thought edu. versions were free?<br />
p-salad	:  	P3D is also going after the owners<br />
jv	:  	Can I just add to that?<br />
jv	:  	OPEN PLANT!<br />
m3	:  	I am going to be honest with you<br />
m3	:  	open plant is a non factor<br />
m3	:  	imho<br />
jv	:  	Seems I may have to learn that pretty effin&#8217; quickly. FML<br />
m3	:  	it&#8217;s a sham<br />
m3	:  	ohhhh<br />
zortar	:  	really<br />
jv	:  	I know that.  YOU know that.  THEY don&#8217;t know that.. haha.  I wept.<br />
p-salad	:  	OP isn&#8217;t any kind of player<br />
p-salad	:  	JV<br />
jv	:  	Oh.. not us.  Client!<br />
m3	:  	that&#8217;s because its a sham!<br />
zortar	:  	Well<br />
p-salad	:  	thats the first i&#8217;ve heard of anyone using it since they demo&#8217;d it back in&#8230;.09<br />
jv	:  	The salesman must have been AWESOME. S&#8217;all I&#8217;m saying.<br />
tkm	:  	we have become a country of marketers instead of builders<br />
m3	:  	lol@tkm<br />
p-salad	:  	i need to become more understanding of what datacentric is and how its different from what we are using now<br />
tkm	:  	almighty dolla<br />
jv	:  	Worst thing is<br />
zortar	:  	It&#8217;s the message<br />
tkm	:  	yes<br />
<br />
<blockquote><br />
<h3 class="cufon">
The fact that schools are standardizing around Plant 3D is their ace in the hole.<br />
</h3>
<p></blockquote><br />
jv	:  	So how now all the major EPC&#8217;s that work for them have to deliver AP models and they have to somehow<br />
zortar	:  	But I don&#8217;t want to get political&#8230;<br />
tkm	:  	the results are less warm :-p<br />
m3	:  	datacentric means the graphics on the screen are just a representation of the database.<br />
jv	:  	make them fit into OP.<br />
zortar	:  	JV<br />
m3	:  	as opposed to graphics that contain data properties from the database.<br />
zortar	:  	Most of our clients have been burned by Bentley so they are steering clear of OpenPlant<br />
m3	:  	think graphical representation of data vs. graphics with data properties<br />
p-salad	:  	ok<br />
m3	:  	THAT&#8217;S BECAUSE ITS A GD SHAM<br />
m3	:  	its a mayco paint job on a 1983 Datsun.<br />
zortar	:  	Well<br />
zortar	:  	lol@m3<br />
p-salad	:  	LOL@3<br />
jv	:  	I&#8217;ll be on here lots.  lamenting.  Weeping.  Banging head.<br />
zortar	:  	JV<br />
m3	:  	Good luck getting past the install procedure<br />
jv	:  	I&#8217;m not worried<br />
m3	:  	soul tried to install it. Same Bentley crap<br />
m3	:  	and make sure the version that runs out to the nth decimal place is the right one else you will need the uninstall procedure.<br />
zortar    :        Bentley: Las Vegas wedding and a Mexican divorce<br />
tkm	:  	LOL<br />
m3	:  	btw there is no uninstall procedure.<br />
m3	:  	lol@Zortar!<br />
jv	:  	My hear SANK when I heard.. but WOW.. can  you imagine that being your first 3D experience?<br />
zortar	:  	The first time is always awkward&#8230;<br />
zortar	:  	&#8230;people say<br />
m3	:  	and painful if you&#8217;re on the receiving end!<br />
tkm	:  	HAHA<br />
zortar	:  	lmao!<br />
m3	:  	ok<br />
jv	:  	YES!!  I needed to know I was not alone in my disdain.  <img src='http://www.davetyner.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
zortar	:  	you are never alone JV<br />
tkm	:  	competitor up here is rumored to be going to SP&#8230;   just not sure if it is going to be all the way or just the PID stuff<br />
jedi	:  	great discussions today kk kept me entertained for sure.<br />
</h6>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/03/invasion-of-the-cad-snatchers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Microeconomics of Plant Design</title>
		<link>http://www.davetyner.com/2013/01/the-microeconomics-of-plant-design/</link>
		<comments>http://www.davetyner.com/2013/01/the-microeconomics-of-plant-design/#comments</comments>
		<pubDate>Sun, 13 Jan 2013 19:23:22 +0000</pubDate>
		<dc:creator>zortar</dc:creator>
				<category><![CDATA[AutoCAD Plant 3D]]></category>
		<category><![CDATA[Autodesk]]></category>
		<category><![CDATA[Autoplant]]></category>
		<category><![CDATA[Editorial]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Plant Software]]></category>
		<category><![CDATA[Smartplant]]></category>
		<category><![CDATA[computing]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[Joel Harris]]></category>
		<category><![CDATA[piping design]]></category>
		<category><![CDATA[Plant Design]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=1909</guid>
		<description><![CDATA[I have to admit to one thing: I really didn&#8217;t like the economics classes I had in college. Maybe it was the fact that I was broke most of the time and the concept of massive economies the size of nations was beyond what I was able to understand at the time. Fast forward to [...]]]></description>
			<content:encoded><![CDATA[<p>I have to admit to one thing: I really didn&#8217;t like the economics classes I had in college.  Maybe it was the fact that I was broke most of the time and the concept of massive economies the size of nations was beyond what I was able to understand at the time.  Fast forward to 2013: I&#8217;m reading this book that a friend recommended to me called &#8220;<a href="http://www.amazon.com/Consumption-Economics-New-Rules-Tech/dp/0984213031">Consumption Economics &#8211; The New Rules of Tech</a>&#8221; by J.B. Wood, Todd Hewlin and Thomas Lah.  More than just reading it, I&#8217;m understanding it &#8211; and believe me it makes a lot of sense.</p>
<blockquote><br />
<h3 class="cufon">
I agree with the authors that this may be the &#8220;next big thing&#8221; in tech<br />
</h3>
<p></blockquote>
<span class="dropcap1">T</span>he basic concept is that there are a number of converging trends in technology today that are changing the face of how it is delivered to the consumer.  Mobile apps, &#8220;the cloud&#8221;, SaaS (Software as a Service), and of all things, the iPhone have paved the way for this new <a href="http://en.wikipedia.org/wiki/Zeitgeist">zeitgeist</a> in the tech world.  I don&#8217;t use that word lightly either: I agree with the authors that this may be the &#8220;next big thing&#8221; in tech. In a nutshell, the power of the consumers to choose a la carte the services, media or apps they want &#8211; and pay for it as they need it &#8211; seems to appeal to the smart shopper in me.  Big dollar, complex enterprise software has definitely paid for more than a few mortgages over the past couple decades but is it the only game in town?  Specifically, when it comes to plant design software: are the top software vendors playing the game the only way it can be played?
<blockquote><br />
<h3 class="cufon">
Mobile apps, &#8220;the cloud&#8221;, SaaS (Software as a Service), and of all things, the iPhone have paved the way for this new <a href="http://en.wikipedia.org/wiki/Zeitgeist">zeitgeist</a> in the tech world</h3>
<p></blockquote>
<div class="frame_center"><a href="http://www.davetyner.com/wp-content/uploads/2013/01/microeconomics005-720p.jpg" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2013/01/microeconomics005-720p.jpg&amp;h=150&amp;w=600&amp;zc=1" alt=""/></a><span class="caption">Plant Design in the Cloud<br />
</span></div>
<span class="dropcap1">I</span> remember when PC CAD software was being ridiculed by the mainframe and mini-computer world at the same time it was sweeping through the schools and mom-and-pop engineering firms. This transformed design all over the world, putting amazing drafting and design tools in the hands of creative people at a fraction of the cost of big-money CAD applications.  Here we are now in the 21st century with the power of the internet, cloud computing and some really fast hardware compared to 1985 &#8211; so why not have another revolution?  In plant design, maybe we designers should demand something other than the current assortment of complex, datacentric software solutions that require a pack of admins to run.
<span class="dropcap1"> </span> Maybe the answer is akin to something like the iTunes App Store.  How about this: instead of paying anywhere from $9000 to $30,000 per seat for a plant design system I just buy the &#8220;base&#8221; application for a $1000 per user and pay as I need more functionality.  Believe me, some of the people I&#8217;ve worked with would do just fine with only the basic functionality; while others would love to do more if it didn&#8217;t cost so much to add on functionality. With just an internet connection, a decent workstation and the input data, I should be able to have the cloud do my isometric generation, stress analysis or clash detection on an as needed basis.
<blockquote><br />
<h3 class="cufon">&#8230;there are still a lot of small and mid-sized engineering firms that balk at the capital expense involved in purchasing, customizing, and deploying a fully-functional plant design platform&#8230;</h3>
<p></blockquote>
<span class="dropcap1">W</span>hy should I fuss with software patches, workstation limitations and configuration headaches when I could pay, say, $0.25 per isometric run.  Pencilling out this hypothetical example, let&#8217;s say a user generates 1000 isos that year, I&#8217;ve still only spent $1250.  Potentially, my small engineering firm could have much the same software functionality of a much larger firm without the extensive initial financial commitment. Why would software companies do this, you ask?  First, running cloud-based apps gives the vendors instantaneous and accurate usage data that could be used to steer future development and marketing efforts.  Also, I think they would attract a loyal and active user base; there are a lot of small and mid-sized engineering firms that balk at the capital expense involved in purchasing, customizing and deploying a fully-functional plant design platform.  Moreover, the cyclical nature of the construction business and project execution poses a unique challenge to companies that aren&#8217;t large enough to merit enterprise-level software licensing.  Having an extensible solution geared to allow those companies to compete and continue to provide excellent service to their industrial clients seems to be the answer.  Otherwise, we may all ultimately end up working at some very large engineering firms with complex software that will always do way more than we need and never what we actually want.
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2013/01/the-microeconomics-of-plant-design/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Dreaded Oracle Block Corruption Error</title>
		<link>http://www.davetyner.com/2012/12/oracle-corrupt-block/</link>
		<comments>http://www.davetyner.com/2012/12/oracle-corrupt-block/#comments</comments>
		<pubDate>Fri, 14 Dec 2012 06:47:06 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Smartplant]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[shawn]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=1794</guid>
		<description><![CDATA[Recently I was hit with the question: (paraphrasing) If there is, I’ve never run into it. In my experience, this has always meant physical block corruption within the data file. The simplest option to correct this is to recover the data from a backup, and roll through the archive/redo logs until the data file is [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was hit with the question: (paraphrasing)</p>
<blockquote></p>
<h3 class="cufon">I just received the error “ORA-01578: ORACLE data block corrupted (file # 11, block # 410112)”. Is there another scenario you can receive this error, without it meaning physical corruption?</h3>
<p></blockquote>
<p>If there is, I’ve never run into it. In my experience, this has always meant physical block corruption within the data file. The simplest option to correct this is to recover the data from a backup, and roll through the archive/redo logs until the data file is healthy again.</p>
<p><span id="more-1794"></span></p>
<p>Unfortunately, it’s not always that easy. There are different backup strategies that can be used in Oracle and which one you use depends on what your needs are. Briefly, I’ll explain the three most common along with some of their pro’s and con’s:</p>
<h3 class="cufon">Logical export</h3>
<p>– This method of backup physically dumps a schema in a portable (albeit proprietary) fashion. This is desirable as you can perform this backup while the database is running, and protects you from incidental accidents. (Dropping a table for instance) It&#8217;s very easy to recover portions of a schema using this method. However, the data in the export is only as current as the time the export was taken. If you only run an export once a day, that’s nearly 24 hours of transactions that may be lost. (Unless also augmented with other techniques to get point in time recovery)</p>
<h3 class="cufon">Physical hot</h3>
<p>– This is a block level backup of the physical data files while the database is running. The requirement for this is that the database must also be in archive log mode. This is a state in which the online redo logs are dumped (archived) to disk periodically, and preserved. (redo logs are basically logs of every transaction)  This gives you the most protection (when done right) as you should never lose any committed transaction. You can do point in time recovery and the database is available during the backup. This takes some strategy, so it’s also the most complex. In addition, partial recoveries are complicated, usually involving recovery to a new instance and transferring data.</p>
<h3 class="cufon">Physical cold</h3>
<p>– This is also a block level backup, much like the hot. You are not restricted to enabling archive log mode, but the database must be down in order to perform the backup. (The database can also be in archive log mode, but if you’re in this mode anyway, might as well just go for the hot backup.. not to say that you have to. There’s plenty of reason to do cold backups even in archive log mode) The pros and cons are similar to hot, except of course, the database must be down and if you’re not in archive log mode, you can’t do point in time recovery. (unless also augmented with other techniques)</p>
<p><div class="frame_left"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2012/12/oracle_render006.png&amp;h=220&amp;w=340&amp;zc=1" alt=""/><span class="caption">Dead Block Must Be Destroyed by SQL<br />
</span></div><br />
Most companies will use a combination of techniques, and most will prefer hot backups if they employ DBA&#8217;s. There are a lot of companies that don&#8217;t have full time DBA&#8217;s and choose the logical, because it&#8217;s easy. Also, some software vendors dictate the strategy. To be honest, I’ve never tried to do point in time recovery with logical and colds (w/o also being in archive log mode), so I don’t honestly know what those would look like, but I assume it’s at least somewhat possible using flashback, log mining, etc. Anyway, I’m getting a bit off-topic, let&#8217;s bring it back.. <img src='http://www.davetyner.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>In this instance, logical backups were chosen, and as far as I know, there was nothing to augment them for point in time recovery. One problem with this choice is that they are susceptible to block corruption too. It’s a row level backup, so if it reaches a corrupt row (block), the backup type will fail. In this case, the backups were in this failing state, so we weren&#8217;t sure how much use they were going to be.</p>
<h4 class="cufon">All is not lost though!!</h4>
<p>There is a chance that this corrupt block could belong to an index which is easily rebuilt w/o any loss. Or, it’s possible that this block is actually empty. I know what you’re thinking, if it’s empty, then why is oracle complaining when querying the table? Because in a full table scan, oracle reads every block until it reaches the high water mark (HWM). Under normal operation, Oracle does not move that HWM back. What does this mean?</p>
<p>Well, if you create a table, load it with 1 million rows, the HWM is positioned at the end of those records. If we then remove those 1 million rows, there will be no data in the table, but the HWM will remain at the previous position. With a full table scan, all the blocks from the beginning of the table, up to the high water mark will be read. In a backup situation, you’d want oracle to read every row, so it will default to a full table scan. (Plus, It takes advantage of multi-block reads for speed) Viola, oracle reads a corrupted block, albeit empty.<br />
You can use this query to determine the segment and segment type that the corrupted block belongs to:</p>
<pre>select owner||'.'||segment_name segment, segment_type from dba_extents where file_id=11 and 410112 between block_id and block_id+blocks;</pre>
<p>The file_id (11) and block number (410112) are taken from the error message above. If segment type returns ‘INDEX’, you can easily rebuild the index with something like: (Substitute [segment] for the segment returned in the above query)</p>
<pre>alter index [segment] rebuild;</pre>
<p>If this segment is a table, I used a few tests to try and determine if the block was empty. As I explained above, if you select the data using a full table scan, you’ll hit the corrupted block. Sooo, that should mean if you access the table with a supporting index, it should avoid corruption in an empty block. Now, this is only going to work if you have an index that fully encompasses the rows, as would be the case with a primary key.</p>
<p>Luckily, we have one of those. Unluckily, that query also failed with the same corrupted block issue. To test this, we used the following SQL, which includes a hint to the optimizer to access this table through an index:</p>
<pre>select /*+ index(a) */ * from schema.table_name a;</pre>
<p>Inversely, if you want to force a full table scan:</p>
<pre>select /*+ full(a) */ * from schema.table_name a;</pre>
<p>I use the term force loosely. Those hints (/*+ function() */) are just that: A hint to Oracle’s optimizer to do something differently than it might try otherwise. Oracle can choose to ignore hints, so we&#8217;re not actually forcing anything. <img src='http://www.davetyner.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  I wasn&#8217;t actually on the system to make sure this actually worked, but since the two resulted in different answers, but both got the same error, I presume it actually did behave the way I intended.</p>
<p>So now what? Well, there is a good chance that there really are rows in the corrupted block. Now the question becomes, how do I recover as much of this data as possible, given the fact that I can’t seemingly touch the table without hitting the corruption?</p>
<p>If we could address every row individually, and directly, we could grab every row and ignore exceptions to skip those in the corrupted block. We already know we have a primary key index, we just need to get all of the primary keys out of it. So how do we query an index? The answer is, you can’t. There is no syntax for selecting data from an index directly. (Well, that I know of anyway) However, Oracle being the smart guys they are, they do have an optimization that basically does just that. Index fast full scan, FTW!</p>
<p>If you’re accessing an indexed column, and the index can cover the dataset completely, Oracle will sometimes use a fast full scan on the index and avoid the extra IO to the table. No point in reading in table blocks, if you don&#8217;t need additional data from it. To nudge Oracle to do this, there’s a hint for that: index_ffs(). Here’s how we got the number of records, utilizing this method:</p>
<pre>select /*+ index_ffs(a) */ count(sp_id) from schema.table_name a;</pre>
<p>Provided there was no funkiness with the constraints/indexes, this should be an accurate count of the number of rows that are (were) in the table. This returned 113524 for us. Once we recover all the rows that we can, the difference is obviously the number of rows that were lost. The next step is to recover the rows. Because this is getting a bit longer than I planned, let me just post the code and I’ll briefly cover it afterwards:</p>
<pre>begin
  for row in (
    select /*+ index_ffs(a) */ distinct
      sp_id
    from
      table_name
  )
  loop
    declare
      v_errm varchar2(2000);
    begin
      insert into table_name_recovery
      select /*+ index(a) */
        *
      from
        table_name a
      where
        a.sp_id = row.sp_id
      ;
    exception
      when others then
        v_errm := substr(sqlerrm,1,1000);
        insert into table_name_errors (sp_id, errm) values (row.sp_id, v_errm);
    end;
  end loop;
  commit;
end;</pre>
<p>Nothing fancy. All the magic is in the hints. Basically, we created an empty copy of the corrupted table (Here&#8217;s a trick: create table A as select * from B where 1=2), and another to throw exceptions and primary keys in. We then ran the above code.</p>
<p>This loops through all the primary keys using the index fast full scan trick. It then selects the row with that primary key from the corrupted table and stores it in our new copy. If this select throws any exceptions, including the corruption error, we record the exception and primary key in the 2<sup>nd</sup> table, and move onto the next row.</p>
<p><div class="frame_right"><a href="http://www.davetyner.com/wp-content/uploads/2012/12/oracle-6.png" class="img_frame"><img src="http://www.davetyner.com/wp-content/themes/Sabuy/timthumb.php?src=http://www.davetyner.com/wp-content/uploads/2012/12/oracle-6.png&amp;h=180&amp;w=320&amp;zc=1" alt=""/></a><span class="caption"><br />
New Healthy Block<br />
</span></div><br />
When it’s done, our new table should have all the rows we can recover from the database. (All but 29 rows in this instance) Where you go from here really depends on the severity and application. In our case, a few more rows were recovered from backups. Perhaps in your case, you can reconstruct them from email, reports, other databases, etc. Might need to get creative here! ;D</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2012/12/oracle-corrupt-block/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MAXScript: Find Area of Circle</title>
		<link>http://www.davetyner.com/2012/12/maxscript-find-area-of-circle/</link>
		<comments>http://www.davetyner.com/2012/12/maxscript-find-area-of-circle/#comments</comments>
		<pubDate>Mon, 10 Dec 2012 13:22:18 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[Autodesk 3DS Max]]></category>
		<category><![CDATA[maxscript]]></category>
		<category><![CDATA[3DS max]]></category>
		<category><![CDATA[dave]]></category>

		<guid isPermaLink="false">http://www.davetyner.com/?p=1559</guid>
		<description><![CDATA[Here is a little script I whipped up in about 15 minutes last night out of pure laziness. My daughters homework was to find the area of a circle based on radius or diameter. There were quite a few problems and I didn&#8217;t want to have to do the calculations each time. So, I came [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a little script I whipped up in about 15 minutes last night out of pure laziness. My daughters homework was to find the area of a circle based on radius or diameter. There were quite a few problems and I didn&#8217;t want to have to do the calculations each time. So, I came up with this. Checking took no time!</p>
<p><code><br />
fn getrad dia ar=(<br />
)<br />
fn getdia rad ar =<br />
(<br />
)<br />
fn getarea rad dia=<br />
(<br />
	if rad>0 then(<br />
		local ar = (rad*rad)*3.14<br />
	)else(<br />
		local r = (dia/2)<br />
		local ar = (r*r)*3.14<br />
	)<br />
	return ar<br />
)<br />
rollout areaFinder "area finder"<br />
(<br />
	spinner spn_radius "radius" range:[0,250000,0] type:#float enabled:false across:2<br />
	checkbox chk_rad<br />
	spinner spn_dia "diameter" range:[0,250000,0] type:#float enabled:false across:2<br />
	checkbox chk_dia<br />
	spinner spn_area "area" range:[0,250000,0] type:#float enabled:false across:2<br />
	checkbox chk_area<br />
	button btn_go "go"<br />
	edittext edit_rad "Radius: "<br />
	edittext edit_dia "Diameter: "<br />
	edittext edit_area "Area: "<br />
		on chk_rad changed state do (<br />
			if spn_radius.enabled==true then spn_radius.enabled=false else spn_radius.enabled=true<br />
		)<br />
		on chk_dia changed state do (<br />
			if spn_dia.enabled==true then spn_dia.enabled=false else spn_dia.enabled=true<br />
		)<br />
		on chk_area changed state do (<br />
			if spn_area.enabled==true then spn_area.enabled=false else spn_area.enabled=true<br />
		)</p>
<p>		on spn_radius changed val do<br />
		(<br />
			local r = spn_radius.value<br />
			local d = 0<br />
			ans = getarea r d<br />
			edit_area.text = ans as string<br />
		)</p>
<p>		on spn_dia changed val do<br />
		(<br />
			local r = 0<br />
			local d = spn_dia.value<br />
			ans = getarea r d<br />
			edit_area.text = ans as string<br />
		)</p>
<p>	on btngo pressed do<br />
				(</p>
<p>				)--end on<br />
)--end rollout<br />
try(destroyDialog areaFinder)catch()<br />
createDialog areaFinder width:200<br />
</code></p>
<h3 class="cufon">To install:</h3>
<p>In 3DS Max select MAXScript > Editor<br />
Paste the code<br />
Press CTRL+E to execute<br />
The Area will be updated by scrubbing either the radius or diameter spinners. You can also just type in a number.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davetyner.com/2012/12/maxscript-find-area-of-circle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.375 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-06-20 01:59:01 -->
