• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

macro quotas

  • Thread starter Thread starter simoness
  • Start date Start date

simoness

Guest
Good morning,
on the false line of this example, which captures all information of the notes of a block,Is there another one that captures me all the quota information of a part/aid?

in the guide I found this example, but as pre-condition, I have to select a single quotaWhat I need instead is that the macro captures all the share/assieme quota values.

the purpose is to intercept all quotas and then go to change only those that interest me.
(the same work done in a previous post, with notes within a block to understand us)

so if you have an example link or want to post something of yours, thank you.
 
Good morning,
on the false line of this example, which captures all information of the notes of a block,Is there another one that captures me all the quota information of a part/aid?

in the guide I found this example, but as pre-condition, I have to select a single quotaWhat I need instead is that the macro captures all the share/assieme quota values.

the purpose is to intercept all quotas and then go to change only those that interest me.
(the same work done in a previous post, with notes within a block to understand us)

so if you have an example link or want to post something of yours, thank you.
la macro che riporto sotto lavora in parte o in assieme. in assieme devi però pre-selezionare un componente e poi la lanci, in ambiente parte lavora solo sulla parte, e ti restituisce il nome e il valore di tutte le quote.
nel caso vuoi passare per tutti i componenti dell'assieme la devi modificare inserendo un ciclo che passa per i componenti dell'albero.



dim swapp as sldworks.sldworks

sub main()

set swapp = application.sldworks

dim swmodel as sldworks.modeldoc2
set swmodel = swapp.activedoc

if not swmodel is nothing then

dim swselmgr as sldworks.selectionmgr

set swselmgr = swmodel.selectionmanager

dim swcomp as sldworks.component2

set swcomp = swselmgr.getselectedobjectscomponent3(1, -1)

if not swcomp is nothing then
traversedimensions swcomp.firstfeature
else
traversedimensions swmodel.firstfeature
end if

else
msgbox "please open document"
end if

end sub

sub traversedimensions(startfeat as sldworks.feature)

dim vfeats as variant
vfeats = getallfeatures(startfeat)

dim vdispdims as variant
vdispdims = getalldimensions(vfeats)

if not isempty(vdispdims) then

dim i as integer

for i = 0 to ubound(vdispdims)

dim swdispdim as sldworks.displaydimension
set swdispdim = vdispdims(i)

dim swdim as sldworks.dimension
set swdim = swdispdim.getdimension2(0)

dim val as double
val = swdim.getsystemvalue3(swinconfigurationopts_e.swthisconfiguration, empty)(0)

debug.print swdim.getnameforselection() & "=" & val

next

end if

end sub

function getalldimensions(vfeats as variant) as variant

dim swdimscoll as collection
set swdimscoll = new collection

dim i as integer

for i = 0 to ubound(vfeats)

dim swfeat as sldworks.feature
set swfeat = vfeats(i)

dim swdispdim as sldworks.displaydimension
set swdispdim = swfeat.getfirstdisplaydimension

while not swdispdim is nothing

if not contains(swdimscoll, swdispdim) then
swdimscoll.add swdispdim
end if

set swdispdim = swfeat.getnextdisplaydimension(swdispdim)
wend

next

getalldimensions = collectiontoarray(swdimscoll)

end function

function getallfeatures(startfeat as sldworks.feature) as variant

dim swprocfeatscoll as collection
set swprocfeatscoll = new collection

dim swfeat as sldworks.feature
set swfeat = startfeat

while not swfeat is nothing

if swfeat.gettypename2() <> "historyfolder" then

if not contains(swprocfeatscoll, swfeat) then
swprocfeatscoll.add swfeat
end if

collectallsubfeatures swfeat, swprocfeatscoll

end if

set swfeat = swfeat.getnextfeature

wend

getallfeatures = collectiontoarray(swprocfeatscoll)

end function

sub collectallsubfeatures(parentfeat as sldworks.feature, procfeatscoll as collection)

dim swsubfeat as sldworks.feature
set swsubfeat = parentfeat.getfirstsubfeature

while not swsubfeat is nothing

if not contains(procfeatscoll, swsubfeat) then
procfeatscoll.add swsubfeat
end if

collectallsubfeatures swsubfeat, procfeatscoll
set swsubfeat = swsubfeat.getnextsubfeature

wend

end sub

function collectiontoarray(coll as collection) as variant

if coll.count() > 0 then

dim arr() as object

redim arr(coll.count() - 1)
dim i as integer

for i = 1 to coll.count
set arr(i - 1) = coll(i)
next

collectiontoarray = arr

else
collectiontoarray = empty
end if

end function

function contains(coll as collection, item as object) as boolean

dim i as integer

for i = 1 to coll.count
if coll.item(i) is item then
contains = true
exit function
end if
next

contains = false

end function
 
hi, sometimes I change accounts because I never remember the pass. one to write from work and one from home?

Anyway, I work allowing, now I can devote myself to this project.
to cycle as you said, I found this
but I find it unspoilt as well as pulling out of everything, less what I need. ?
I would use this, then you will have to work in "sub traversefeatures ..."
 
Hi, I solved as follows.
It is true that it detects all the quotas of all the components (even the repeated ones), but with ifs or houses (now I see), I go to intercept what I need.

edit: I detect all the sketches and functions of the parts that make up a set, without selecting any part. (which is good, that's what I wanted to get)non rileva però, le funzioni di assieme. non che ne avessi bisogno, ma non si sa mai
qualche idea su come migliorarlo?

option explicit

public swapp as sldworks.sldworks


sub main()


dim swmodel as sldworks.modeldoc2
dim swassy as sldworks.assemblydoc
dim vcomp as variant
dim swcomp as sldworks.component2
dim i as integer
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swassy = swmodel
vcomp = swassy.getcomponents(false)

for i = 0 to ubound(vcomp)
set swcomp = vcomp(i)
if not swcomp is nothing then
traversedimensions swcomp.firstfeature
else
traversedimensions swmodel.firstfeature
end if
next i

end sub



sub traversedimensions(startfeat as sldworks.feature)

dim vfeats as variant
vfeats = getallfeatures(startfeat)

dim vdispdims as variant
vdispdims = getalldimensions(vfeats)

if not isempty(vdispdims) then

dim i as integer

for i = 0 to ubound(vdispdims)

dim swdispdim as sldworks.displaydimension
set swdispdim = vdispdims(i)

dim swdim as sldworks.dimension
set swdim = swdispdim.getdimension2(0)

dim val as double
val = swdim.getsystemvalue3(swinconfigurationopts_e.swthisconfiguration, empty)(0)

debug.print swdim.getnameforselection() & "=" & val
if swdim.name = "altezza_cumulo" then
swdim.value = 5000
end if

next

end if
dim swmodel as sldworks.modeldoc2
set swmodel = swapp.activedoc
dim ret as boolean
ret = swmodel.forcerebuild3(false)

end sub

function getalldimensions(vfeats as variant) as variant

dim swdimscoll as collection
set swdimscoll = new collection

dim i as integer

for i = 0 to ubound(vfeats)

dim swfeat as sldworks.feature
set swfeat = vfeats(i)

dim swdispdim as sldworks.displaydimension
set swdispdim = swfeat.getfirstdisplaydimension

while not swdispdim is nothing

if not contains(swdimscoll, swdispdim) then
swdimscoll.add swdispdim
end if

set swdispdim = swfeat.getnextdisplaydimension(swdispdim)
wend

next

getalldimensions = collectiontoarray(swdimscoll)

end function

function getallfeatures(startfeat as sldworks.feature) as variant

dim swprocfeatscoll as collection
set swprocfeatscoll = new collection

dim swfeat as sldworks.feature
set swfeat = startfeat

while not swfeat is nothing

if swfeat.gettypename2() <> "historyfolder" then

if not contains(swprocfeatscoll, swfeat) then
swprocfeatscoll.add swfeat
end if

collectallsubfeatures swfeat, swprocfeatscoll

end if

set swfeat = swfeat.getnextfeature

wend

getallfeatures = collectiontoarray(swprocfeatscoll)

end function

sub collectallsubfeatures(parentfeat as sldworks.feature, procfeatscoll as collection)

dim swsubfeat as sldworks.feature
set swsubfeat = parentfeat.getfirstsubfeature

while not swsubfeat is nothing

if not contains(procfeatscoll, swsubfeat) then
procfeatscoll.add swsubfeat
end if

collectallsubfeatures swsubfeat, procfeatscoll
set swsubfeat = swsubfeat.getnextsubfeature

wend

end sub

function collectiontoarray(coll as collection) as variant

if coll.count() > 0 then

dim arr() as object

redim arr(coll.count() - 1)
dim i as integer

for i = 1 to coll.count
set arr(i - 1) = coll(i)
next

collectiontoarray = arr

else
collectiontoarray = empty
end if

end function

function contains(coll as collection, item as object) as boolean

dim i as integer

for i = 1 to coll.count
if coll.item(i) is item then
contains = true
exit function
end if
next

contains = false

end function
 
Hi, I solved as follows.
It is true that it detects all the quotas of all the components (even the repeated ones), but with ifs or houses (now I see), I go to intercept what I need.

edit: I detect all the sketches and functions of the parts that make up a set, without selecting any part. (which is good, that's what I wanted to get)non rileva però, le funzioni di assieme. non che ne avessi bisogno, ma non si sa mai
qualche idea su come migliorarlo?

option explicit

public swapp as sldworks.sldworks


sub main()


dim swmodel as sldworks.modeldoc2
dim swassy as sldworks.assemblydoc
dim vcomp as variant
dim swcomp as sldworks.component2
dim i as integer
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swassy = swmodel
vcomp = swassy.getcomponents(false)

for i = 0 to ubound(vcomp)
set swcomp = vcomp(i)
if not swcomp is nothing then
traversedimensions swcomp.firstfeature
else
traversedimensions swmodel.firstfeature
end if
next i

end sub



sub traversedimensions(startfeat as sldworks.feature)

dim vfeats as variant
vfeats = getallfeatures(startfeat)

dim vdispdims as variant
vdispdims = getalldimensions(vfeats)

if not isempty(vdispdims) then

dim i as integer

for i = 0 to ubound(vdispdims)

dim swdispdim as sldworks.displaydimension
set swdispdim = vdispdims(i)

dim swdim as sldworks.dimension
set swdim = swdispdim.getdimension2(0)

dim val as double
val = swdim.getsystemvalue3(swinconfigurationopts_e.swthisconfiguration, empty)(0)

debug.print swdim.getnameforselection() & "=" & val
if swdim.name = "altezza_cumulo" then
swdim.value = 5000
end if

next

end if
dim swmodel as sldworks.modeldoc2
set swmodel = swapp.activedoc
dim ret as boolean
ret = swmodel.forcerebuild3(false)

end sub

function getalldimensions(vfeats as variant) as variant

dim swdimscoll as collection
set swdimscoll = new collection

dim i as integer

for i = 0 to ubound(vfeats)

dim swfeat as sldworks.feature
set swfeat = vfeats(i)

dim swdispdim as sldworks.displaydimension
set swdispdim = swfeat.getfirstdisplaydimension

while not swdispdim is nothing

if not contains(swdimscoll, swdispdim) then
swdimscoll.add swdispdim
end if

set swdispdim = swfeat.getnextdisplaydimension(swdispdim)
wend

next

getalldimensions = collectiontoarray(swdimscoll)

end function

function getallfeatures(startfeat as sldworks.feature) as variant

dim swprocfeatscoll as collection
set swprocfeatscoll = new collection

dim swfeat as sldworks.feature
set swfeat = startfeat

while not swfeat is nothing

if swfeat.gettypename2() <> "historyfolder" then

if not contains(swprocfeatscoll, swfeat) then
swprocfeatscoll.add swfeat
end if

collectallsubfeatures swfeat, swprocfeatscoll

end if

set swfeat = swfeat.getnextfeature

wend

getallfeatures = collectiontoarray(swprocfeatscoll)

end function

sub collectallsubfeatures(parentfeat as sldworks.feature, procfeatscoll as collection)

dim swsubfeat as sldworks.feature
set swsubfeat = parentfeat.getfirstsubfeature

while not swsubfeat is nothing

if not contains(procfeatscoll, swsubfeat) then
procfeatscoll.add swsubfeat
end if

collectallsubfeatures swsubfeat, procfeatscoll
set swsubfeat = swsubfeat.getnextsubfeature

wend

end sub

function collectiontoarray(coll as collection) as variant

if coll.count() > 0 then

dim arr() as object

redim arr(coll.count() - 1)
dim i as integer

for i = 1 to coll.count
set arr(i - 1) = coll(i)
next

collectiontoarray = arr

else
collectiontoarray = empty
end if

end function

function contains(coll as collection, item as object) as boolean

dim i as integer

for i = 1 to coll.count
if coll.item(i) is item then
contains = true
exit function
end if
next

contains = false

end function
nothing, you have to move the code to the previous macro, the one that passes the feature manageron this, in the select case, you have to treat the node as a feature, if then it is a component you pass it to the function that scans it, otherwise the tract like a real feature, i.e. a workmanship, where by means of a gettype check what type it is and if you do it to your case you pull out the odds.
not;
 
Well... at the end of the day I did not understand a fava of what you wrote:\
You know, I'm not a vba programmer, I'm going on self-taught.

Your "simple" worries me
 
Well... at the end of the day I did not understand a fava of what you wrote:\
You know, I'm not a vba programmer, I'm going on self-taught.

Your "simple" worries me
hi, I understand that it is not simple, more than anything else is having the logic of the steps to do in the head, then the code you put it accordingly.
to help you in writing, I attached you the macro with comments, which explains the steps it does so that you can help you understand logic.
I recommend you to try to create a set with a component in it with a solid. then make a cutting extrusion assembly function that intersects the component. so you create the situation you wanted and then throw the macro.
You will notice that it passes all the functions of the tree, if it is a component then you do what you need, if it is a function, it filters a couple of cases, you can expand it to pleasure, and also here you do what you want to the feature, in your case you will return the odds.
You will see that with the comments you find on the macro you understand immediately:).
Let me know.
 

Attachments

hi, I understand that it is not simple, more than anything else is having the logic of the steps to do in the head, then the code you put it accordingly.
to help you in writing, I attached you the macro with comments, which explains the steps it does so that you can help you understand logic.
I recommend you to try to create a set with a component in it with a solid. then make a cutting extrusion assembly function that intersects the component. so you create the situation you wanted and then throw the macro.
You will notice that it passes all the functions of the tree, if it is a component then you do what you need, if it is a function, it filters a couple of cases, you can expand it to pleasure, and also here you do what you want to the feature, in your case you will return the odds.
You will see that with the comments you find on the macro you understand immediately:).
Let me know.
a thousand thanks, to read the comments, does even more than due o_o
I study and thank you again.
 
hi, I understand that it is not simple, more than anything else is having the logic of the steps to do in the head, then the code you put it accordingly.
to help you in writing, I attached you the macro with comments, which explains the steps it does so that you can help you understand logic.
I recommend you to try to create a set with a component in it with a solid. then make a cutting extrusion assembly function that intersects the component. so you create the situation you wanted and then throw the macro.
You will notice that it passes all the functions of the tree, if it is a component then you do what you need, if it is a function, it filters a couple of cases, you can expand it to pleasure, and also here you do what you want to the feature, in your case you will return the odds.
You will see that with the comments you find on the macro you understand immediately:).
Let me know.
I'm gonna have to work here for a while.
the first project, that of the import of the blocks to be compiled with the userforms, was much easier.

now, given the axieme, the new idea of macro, will have to do:
- userform startup, numerical data entry
-reading configurations of the whole tree
-creation of a new configuration of the main axieme (and vague. easy) and subassis/parties involved (I am still here). will also have to delete all existing configurations that have the same name as the new input (only for the main axieme for now)
-variations models through the numerical data entered with the userform (made with the macro placed the other day)
- total update

you have no idea how hard I am to navigate the feature tree:'(
 
overall view seems tough, but it is less than it seems.
when you give ok to the userform I would do:
  1. add configuration to the axieme
  2. a getcomponents and with the array of components obtained for each verify if there is the configuration, if you delete it and remake it and change the values that you desire
  3. scan the axieme for feature, remaining at the zero level, if you find feature of the values together
 
overall view seems tough, but it is less than it seems.
when you give ok to the userform I would do:
  1. add configuration to the axieme
  2. a getcomponents and with the array of components obtained for each verify if there is the configuration, if you delete it and remake it and change the values that you desire
  3. scan the axieme for feature, remaining at the zero level, if you find feature of the values together
actually seemed harder.
Now I just want to tell them to assign the new child configurations to the new configuration together. ;)
 
actually seemed harder.
Now I just want to tell them to assign the new child configurations to the new configuration together. ;)
well done, sometimes it is necessary to throw in and you realize that it is not so difficult. the starting code more than half of the work this time.
 
..the starting code more than half the work this time.
I didn't understand that.

Anyway, now that I look at the code I wrote, it's not even that long and I wonder why I put so much to write it.
I didn't know vba until a few months ago, but now that I'm trying, by satisfaction, I like it.
 
Sorry... I said that the starting code of this macro, so the part of traverse features, was a pre-packaged structure where to go to add the share recovery part.
 
Sorry... I said that the starting code of this macro, so the part of traverse features, was a pre-packaged structure where to go to add the share recovery part.
Yes, I did, but I just took the cue, I didn't exactly use that code.
a few minutes and I put it attached
 
and here is that the owner has lifted the asticella again.
I need help.

given a set where I create a new configuration, for main group and children, quotas/features/equations, must be able to change only in the new configuration.

I need a start, a point please
 
and here is that the owner has lifted the asticella again.
I need help.

given a set where I create a new configuration, for main group and children, quotas/features/equations, must be able to change only in the new configuration.

I need a start, a point please
should be simple because in the method "isetvalue3 method (idimension)" set the configuration for the value change of the quota
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top