Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re: Macro to create an Isometric View on a CATDrawing

Status
Not open for further replies.

cstark

Aerospace
Jan 4, 2017
1
US
thread560-401763

Hi, I figured I would join since this forum has helped me numerous times before.

In the referenced thread above, the OP asks how to create an Isometric View in a CatDrawing and set it to Raster mode. I had trouble with his formula to find vector1 to generate the Iso so I am posting what I found to work, and how to render the view as raster.

Be pre-warned, I am not a computer programmer by trade and my last VBScript class was 10+ years ago in high school. So my code may not be the most efficient or cleanest. Any tips are welcome. :)

Also, my script is .catvbs so my declarations do not have "as string", etc.

First, we need to modify some Catia Settings so the default view generation mode is Raster
Code:
Dim settingControllers1
Set settingControllers1 = CATIA.SettingControllers
Dim settingRepository1
Set settingRepository1 = settingControllers1.Item("DraftingOptions")

Dim CurrentSetting1,CurrentSetting2,CurrentSetting3,CurrentSetting4
CurrentSetting1 = settingRepository1.GetAttr("CATDrwLODPrintMod")     'capture current setting for Drafting>View>raster print quality
CurrentSetting2 = settingRepository1.GetAttr("CATDrwRasterMod")       'capture current setting for Drafting>View>raster mode
CurrentSetting3 = settingRepository1.GetAttr("DrwGenerationModeVal")   'capture current setting for Drafting>View>view generation mode
CurrentSetting4 = settingRepository1.GetAttr("CATDrwLODVisuMod")         'capture current setting for Drafting>View>raster print quality
	
settingRepository1.PutAttr "DrwGenerationModeVal", 2                      'change to raster mode
settingRepository1.PutAttr "CATDrwRasterMod", 2                         'change to shading with edges
settingRepository1.PutAttr "CATDrwLODPrintMod", 1                        'normal quality
settingRepository1.PutAttr "CATDrwLODVisuMod", 1                         'normal quality

Let's get the vectors for the current 3D view, "Up" and "Sight"
Code:
viewer3D1.viewpoint3D.GetUpDirection Up
viewer3D1.viewpoint3D.GetSightDirection Sight

Now we need to find the cross product vector which gives us the missing leg of the trihedron
Code:
Dim Sight0,Sight1,Sight2	
Sight0 = -1*( (Up(1))*(Sight(2)) - (Up(2))*(Sight(1)) )           'WARNING - this has worked in 4 tests, but further verification is needed to make sure the -1* is always needed
Sight1 = (Up(0))*(Sight(2)) - (Up(2))*(Sight(0))
Sight2 = -1*( (Up(0))*(Sight(1)) - (Up(1))*(Sight(0)) )           'WARNING - this has worked in 4 tests, but further verification is needed to make sure the -1* is always needed

We can now generate the Iso view
Code:
drawingViewGenerativeBehavior1.DefineIsometricView Sight0,Sight1,Sight2,Up(0),Up(1),Up(2)

Finally, we revert the changed Catia Settings
Code:
settingRepository1.PutAttr "CATDrwLODVisuMod", CurrentSetting4
settingRepository1.PutAttr "DrwGenerationModeVal", CurrentSetting3
settingRepository1.PutAttr "CATDrwRasterMod", CurrentSetting2
settingRepository1.PutAttr "CATDrwLODPrintMod", CurrentSetting1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top