Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Create Dimension with VBA in drafting

Status
Not open for further replies.

farzad89

Mechanical
May 9, 2014
23
Hello
Is it possible to create a dimension for a line or a circle or etc with VBA in drafting in Catia V5 ?
 
Replies continue below

Recommended for you

Thanks Fernando for your reply,

I searched in v5automation.chm, but I could not find a sample code about to create a dimension for a GeneratedItem in drafting. my problem is, how can I set a dimension for a specific GeneratedItem that I want, like a Line (GeneratedItem) or a circle with vba in drafting. I need a sample code ?

I want to select a specific GeneratedItem, like a line or a circle that I want to get dimension for it
Exactly my mean is
 
 http://files.engineering.com/getfile.aspx?folder=8bc4db69-f365-47f0-8206-d120e76d2fe5&file=Drafting.png
In the drawing that I attached, there is a dimension between to holes, I want to set this dimension with VBA (without Selected by the user) ?
 
I recorded a CatScript to set a dimension between two holes (for the picture in the last post) :

[Sub CATMain()

Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")

Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views

Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.Item("Front view")

Dim drawingDimensions1 As CATBaseDispatch
Set drawingDimensions1 = drawingView1.GetItem("")

Dim drawingDimension1 As DrawingDimension
Set drawingDimension1 = drawingDimensions1.Item("Dimension.1")

Dim boolean1 As Boolean
boolean1 = drawingDimension1.Forshortened

End Sub]

my problem is:
[highlight #FCAF3E]Set drawingDimensions1 = drawingView1.GetItem("")[/highlight]
[highlight #EF2929]GetItem("between what ?!")[/highlight]

I can't extract Items (Holes) name or type! how can I do this ?
 
Here is an idea:
In the model, create another sketch.
In that sketch put points at the center of the circles.
Create a length dimension between the points.
Make that dimension reference.(this creates something called a Measured Constraint)

On the drawing, use the Generate Dimensions tool.
Toggle OFF Sketcher Constraints.
Toggle ON Measured Constraints.
Toggle ON ....associated with unrepresented elements.
Click OK to create the "dimension". (which is really just showing the measured constraint)

This is a way to pre-dimension your drawing while still in the part.


 
Thanks garzar for your suggest and your idea,

your idea is effective but it requires some design considerations and I want to set a dimension for a Item (like a line or a circle or between two circles etc) with vba in drafting worbench. My question is, when I recorded CatScript for posted example, there is not name for Items!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor