Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Create an Isometric View from the active catPart with VB6 1

Status
Not open for further replies.

Lea75

Mechanical
Feb 24, 2009
51
Hi all! and Happy New Year!
Can someone help me with a short VB6 code that I need?
The idea is simple:
I need to create an isometric view in catdrawing of the current view of my catPart.
It is like to take a photo of my solid in the same position as it is in a 2D drawing.
I don't know how to start and I couldn't find something similar in the web.
Thank you in advance.
Kind regards
 
Replies continue below

Recommended for you

did you check the V5Automation.chm file? you should find an example about how to create a front view, and enough information to change the code in order to create the isometric view. Show your progress I will help.

Eric N.
indocti discant et ament meminisse periti
 
Hi, thank you for your reply
I was already able to create a front view, but I don't have any idea to take the correct parameters of position/rotation of the current view to set an isometric in drawing

oDrawingViewGenerativeBehavior.DefineIsometricView ¿0, 0, 0, 0, 0, 0?
 
in the chm file look for Viewpoint3D

you're almost there...

Eric N.
indocti discant et ament meminisse periti
 
I'm not being able to find the right parameters to fill in this command
oDrawingViewGenerativeBehavior.DefineIsometricView ¿0, 0, 0, 0, 0, 0?

I've already checked viewpoint3D but I'm lost
(I'm not an expert of CATIA Automation)
Any other tip or example?

I tried to record a macro and this is the result:

Sub CATMain()
Set drawingDocument1 = CATIA.ActiveDocument
Set drawingSheets1 = drawingDocument1.Sheets
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.Add("AutomaticNaming")
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
Set documents1 = CATIA.Documents
Set productDocument1 = documents1.Item("OF 10889(A) - PLANTILLA - 2511083201 - MAGNA.CATProduct")
Set product1 = productDocument1.Product
drawingViewGenerativeBehavior1.Document = product1
drawingViewGenerativeBehavior1.DefineIsometricView 0.801471, -0.464663, 0.376474, 0.592154, 0.704671, -0.390886
drawingView1.x = 210.000000
drawingView1.y = 148.500000
drawingView1.Scale = 1.000000
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeBehavior1.Update
drawingView1.Activate
End Sub


I need yo automate thess parameters but I don't know how to extract them from the active view
 
Viewpoint3D.GetSightDirection and Viewpoint3D.GetUpDirection should help you.

Eric N.
indocti discant et ament meminisse periti
 
Hi, I think I am near the solution, but I still don't reach the good result. I'm using VB6:
...
' Get the viewer
Dim oViewer As Viewer
Set oViewer = CATIA.ActiveWindow.ActiveViewer

' Get the viewpoint
Dim oviewpoint As Viewpoint3D
Set oviewpoint = oViewer.Viewpoint3D

' Get the current parameters
Dim vSightDirection(2) As Variant
Dim vUpDirection(2) As Variant
Dim vViewpoint As Variant

Set vViewpoint = oviewpoint
vViewpoint.GetSightDirection vSightDirection
vViewpoint.GetUpDirection vUpDirection

...
oDrawingViewGenerativeBehavior.DefineIsometricView vSightDirection(0), vSightDirection(1), vSightDirection(2), vUpDirection(0), vUpDirection(1), vUpDirection(2)
oDrawingViewGenerativeBehavior.Update
...

The generated Isometric view is not the same as the current Product view.
Where's the problem?
 
that is because the view in drawing is defined with H and V vectors

the V vector you have form GetUpDirection

the H direction you have to compute from UpDirection and SightDirection

Eric N.
indocti discant et ament meminisse periti
 
I don't know how to compute the H direction. Sorry for the ignorance.
As I understood...
I should create a Hvector:

Dim vHVector(2) As Variant
vHVector(0) = ???? how I calculate these components with vSightDirection and vUpDirection?
vHVector(1) = ????
vHVector(2) = ????

.... then...
oDrawingViewGenerativeBehavior.DefineIsometricView vHVector(0), vHVector(1), vHVector(2), vUpDirection(0), vUpDirection(1), vUpDirection(2)

I almost get it. I hope you could give me the last tip to finish this issue.
Thank you for the patience ;)
 
After serching and serching for a solution I finally get it from a similar post in this forum:

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 --> CATVBS
drawingViewGenerativeBehavior1.DefineIsometricView Sight0,Sight1,Sight2,Up(0),Up(1),Up(2)

This worked for me, and hope it would be usefull for someone else.
Thank you very much Eric!
 
so happy you manage to make it!

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor