Solidworks, macro for scale

Hello

To follow up on my 1st question:

http://www.lynkoa.com/forum/2d/solidworks-macro-qui-pointe-vers-une-propriete#answer-641585

The macro proposed by .PL works but with some "limit" that I would like to improve.

1) This macro only includes integer values, which is complicated to make 1:2 scales for example. I would like to be able to enter a 0.5 scale and that it is taken into account by the macro.

2) The macro will look for the value of the scale in the file properties of the part in the "Customize" tab with the type "Number". So I can't create a relationship between my $PROPRIETE@SCALE property that is generated in "Configuration Specific" and not in "Customize". Is it possible to point the source of the macro scale to a "Text" type? That way I can create a relationship between the two tabs.

Thank you

Hello,

 

I use a small piece of code for scaling up. I think it should be able to be modified for your case (I do everything in the car, but with a question box on the scale, you should be able to modify that)

 

Obtaining current scale in fraction format (a:b)
Dim swView As SldWorks.View
Set swView = swdoc. GetFirstView
Dim ech As Variant
ech = swView.ScaleRatio

'We set to a scale of 1:1
ech1 = swSheet.SetScale(1, 1, True, True)

'we return to the initial scale, ech(0) for numerator and ech(1) for denomitator
ech1 = swSheet.SetScale(ech(0), ech(1), True, True)

1 Like

Hello coin37coin

Can you make me pass your macro as a text file?

I can't change the snippet of code you gave me with my macro... (I'm not very good at macro)

Copy and paste not working? Finally you will find it in the attached text file:)

 

Edit: as long as the modification for your macro, I absolutely did not follow the construction of it. So I don't really know what you went from to go where. It was just a snippet of code for you to see how to make the fractions in scale and interclate it in your VBA

But I'm sure @.PL will be able to guide you through the dangerous meanders of his macro


obtention_echelle_actuelle_en_format_fraction.doc
1 Like

Hello

Here's an example for configuration-specific properties:

http://help.solidworks.com/2014/English/api/sldworksapi/Get_Custom_Properties_for_Configuration_Example_VB.htm

The instructions to use are:

 Set config = swModel.GetActiveConfiguration
 Set cusPropMgr = config. CustomPropertyManager

And then, I think it's:

    lRetVal = cusPropMgr.Get5("ADATE", False, ValOut, ResolvedValOut, wasResolved)
 

See here:

http://help.solidworks.com/2014/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ICustomPropertyManager~Get5.html

And for your integer problem, add this at the beginning:

Dim Double Scale As

1 Like

.PL

I'm sorry but nothing done... My lack of programming knowledge is probably to blame.

The problem always remains the same...

It's okay it works,

Using a sketch as a scale that serves as a reference in my file properties that I can control.