VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

multiple dimension dxf generation

4 REPLIES 4
Reply
Message 1 of 5
arnold_noel
490 Views, 4 Replies

multiple dimension dxf generation

hello,

 

i have created a simle part file which has a User parameter (L). The part should be cut with a laser cutting machine.

 

My problem is, that there is 76 different dimensions for L parameter. So I have to generate 76 different dxf drawing.

 

is there a way to crearte a VBA code for modifying the L parameter, regenerate the part file, and export the surface of the part file as a DXF file?

 

regards,

arnold

4 REPLIES 4
Message 2 of 5
Hallex
in reply to: arnold_noel

My guess is to wrte a functiont hat will draw your detail, depending on the value of the L parameter,
and then select the newly created item and then write selection to a dwg file using WBLOCK ,
then open it and resave a file as dxf and at the end delete previous dwg file usingKILL method
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 5
Hallex
in reply to: arnold_noel

Here is quick example, was written in a hurry,

so check all names and value

''--- Borrowed from on Juergen Menzi ---''
Public Sub WblockSelection(detailName As String, Lparam As Double)

  Dim wdoc As AcadDocument

  Dim SelSet As AcadSelectionSet

    
  Set SelSet = NewSelectionSet("WBLOCK_SET")
 
  With ThisDrawing
    SelSet.SelectOnScreen

   Dim path As String
   path = .FullName
   Dim dwgName As String
   dwgName = detailName & "_" & Replace(CStr(Lparam), ",", "_", 1, -1, vbTextCompare)
   Dim outFile As String
   outFile = .GetVariable("dwgprefix")
   outFile = outFile & dwgName & ".dwg"
  .Wblock outFile, SelSet
  End With
  Dim dxfFolder As String
  dxfFolder = "C:\Test\DxfFolder\"
  Dim dxfName As String
  dxfName = dxfFolder & dwgName & ".dxf"
Set wdoc = Application.Documents.Open(outFile, False, "")
Call wdoc.SaveAs(dxfName, ac2000_dxf, Nothing)
wdoc.Close
Kill outFile

End Sub



Public Function NewSelectionSet(AssNme As String) As AcadSelectionSet
  Dim SelSet As AcadSelectionSet
  Dim SelCol As AcadSelectionSets
  With ThisDrawing
    Set SelCol = .SelectionSets
    For Each SelSet In SelCol
      If SelSet.Name = AssNme Then
        .SelectionSets.Item(AssNme).Delete
        Exit For
      End If
    Next
    Set SelSet = .SelectionSets.Add(AssNme)
  End With
  Set NewSelectionSet = SelSet
End Function


Public Sub Test_Wblock()
Dim lpar As Double
lpar = 1200.5
Dim shp As String
shp = "FOO"
Call WblockSelection(shp, lpar)
End Sub

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 5
arnold_noel
in reply to: Hallex

thanks for the example.

 

is this for autocad?

 

I have 3-4 dimensions driven of this L parameter. can the part generation be done in autocad?

 

i don't really understand ehat are you doing in the NewSelectionSet function.

your function should update the part with the new dimensions?

 

 

Message 5 of 5
Hallex
in reply to: arnold_noel

This code will work with existing details, say if these has different L parameter

and yoiu now yhis value as well as detail name then you can create dxf's using this code

Or you wanted be on another lanfguage, say VB.NET or C#?

Also you could be uppload the picture here to show your detail

But sorry I can more help. some my own proble occurs

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost