Sketch Point Import Macro Mod

Programming and macros
dave.laban
Posts: 320
Joined: Thu Mar 11, 2021 8:38 am
Answers: 5
x 48
x 390

Sketch Point Import Macro Mod

Unread post by dave.laban »

Probably one for Artem but just in case anyone else knows how:

I want to create a sketch with a bunch of known points (that I already have in CSV format) so this macro is pretty much perfect.

However rather than using the global coordinate system, I was hoping to use a coordinate system I have inserted to define the origin for where the points are placed. Can this macro be modified to prompt me to select a different coordinate system?

Also less critically, my data is natively in mm where the macro requires metres. Obviously it is trivial to update the source data but it would be one less step if maybe the macro could read the document units and import as that, would that be possible?
User avatar
AlexB
Posts: 499
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 28
x 267
x 444

Re: Sketch Point Import Macro Mod

Unread post by AlexB »

dave.laban wrote: Wed Aug 11, 2021 9:24 am However rather than using the global coordinate system, I was hoping to use a coordinate system I have inserted to define the origin for where the points are placed. Can this macro be modified to prompt me to select a different coordinate system?
I feel like you'd have to transform the coordinates to the reference coordinate system with something like:
https://help.solidworks.com/2019/englis ... ple_VB.htm
dave.laban wrote: Wed Aug 11, 2021 9:24 am Also less critically, my data is natively in mm where the macro requires metres. Obviously it is trivial to update the source data but it would be one less step if maybe the macro could read the document units and import as that, would that be possible?
Yes, this would be relatively simple to create a conversion function that looks for common units and applies a conversion to any measurements during the import of all the points from your CSV. Meters is such an uncommon unit that you would likely have to convert units anyway.
Austin Schukar
Posts: 98
Joined: Thu Mar 18, 2021 11:19 am
Answers: 1
Location: St. Louis, MO
x 288
x 56

Re: Sketch Point Import Macro Mod

Unread post by Austin Schukar »

Here is another example on CS transformation, from CodeStack:

https://www.codestack.net/solidworks-ap ... transform/
Austin
artem
Posts: 26
Joined: Thu Mar 18, 2021 1:31 pm
Answers: 3
x 9
x 74

Re: Sketch Point Import Macro Mod

Unread post by artem »

@dave.laban, I have updated the original macro and you can now pre-select coordinate system to import points relative to. And you also have an option to import points using the current document coordinate system. I have updated the macro and you can redownload from CodeStack. Please let me know if you have any questions.
Thanks,
Artem
xarial.com - making your CAD better
codestack.net - SOLIDWORKS API macros and tutorials
Post Reply