[MACRO] [SW2013] Drive an extrusion from an assembly

Hello

I'm writing to you because despite my research I'm stuck on an automation project under Solidworks 2013.

I'm going to put the context back in place:

I created a macro that opens a UserForm in which the user enters various information. At validation, assembly, a rail system, this modifies by adapting its length. In fact, I take the length desired by the user and I incorporate a maximum of "standard" rails that have a fixed length. This leaves a final stretch that must be tailor-made.

I have in my assembly a "specific" piece of rail that is positioned in the right place and on which I would like to vary the length of the remaining value (which I know, and which is already linked to a variable).

I tried to do this in several ways:

  • Directly in the assembly by selecting ma_cote@ma_piece@mon_assemblage
  • By doing a part.editpart, then a modification and a part.editassembly

Do you have an idea of what to do or which order I should turn to? Or maybe it's impossible?

Thank you in advance if you can think of a lead:)

Kind regards

Hello

Are you talking about a normal part or a virtual part during assembly?

Hello!

The custom-made rail is a normal part

Kind regards

So you have to open the room:

http://help.solidworks.com/2013/english/api/sldworksapi/Open_Document_Example_VB.htm

To change a dimension:

http://help.solidworks.com/2013/english/api/sldworksapi/Change_Dimension_Example_VB.htm

And we can do this in the background:

http://help.solidworks.com/2011/English/api/sldworksapi/Enable_Background_Processing_When_Opening_Drawing_Document_Example_VB.htm

 

2 Likes

Fantastic

I'm looking at it right away and I'm trying to make a return in the afternoon.

Kind regards

1 Like

Hello

Despite my attempts I was not able to use the functions offered by .PL.

I was still able to get by using an editpart that looks like this:

Part.Extension.SelectByID2("PREMIER_RAIL-1", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Part.EditPart
Dim myDimension As Object
Set myDimension = Part.Parameter("D1@Boss.-Extru.1@PREMIER_RAIL. Part")
myDimension.SystemValue = TextBox15.Text / 1000
Part.ClearSelection2 True
boolstatus = Part.EditRebuild3()
Part.EditAssembly

 

Thank you very much for your time and for the information that allowed me to improve my search

If you can post your full macro in a text file, it allows everyone to enjoy your code:)