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

manage positions seen drawing from vba

  • Thread starter Thread starter Barone_Birra
  • Start date Start date

Barone_Birra

Guest
Good morning, I'm facing the following problem:

set the position of a design view on a vba draft with the command "vista.setorigin(x,y)".
the question is how do I know which point of view I'm going to place?
example: I put on the table a cylinder and in the view where you see the base area (so a circle) with the command above indicated and with coordinates (0.0) makes me combine the center of the circle with the lower left corner of the sheet (in this case a4) from which I deduce that I am assigning the coordinates to the center of the circle; same command with the front view (where the table corresponds to a rectangle) I put again (0,0) but the rectangle I see it with the axis aligned to the bottom corner of the sheet but the rectangle is all "under" as if the check point (0,0) in my view was on the axis but above the cylinder out of the figure.

I tried to show the reference axes of the views from (project body->elenca all-> axis x ->mostra assey->mostra siz->mostra) and the reference axes of the two views are not overlapped so I am not assigning the coordinates (0,0) at the origin of the axes.

the question is therefore according to the view which point of them is the reference that assumes the coordinates given by "vista.setorigin(0,0)"?

Thank you.
 
Good morning, I'm facing the following problem:

set the position of a design view on a vba draft with the command "vista.setorigin(x,y)".
the question is how do I know which point of view I'm going to place?
example: I put on the table a cylinder and in the view where you see the base area (so a circle) with the command above indicated and with coordinates (0.0) makes me combine the center of the circle with the lower left corner of the sheet (in this case a4) from which I deduce that I am assigning the coordinates to the center of the circle; same command with the front view (where the table corresponds to a rectangle) I put again (0,0) but the rectangle I see it with the axis aligned to the bottom corner of the sheet but the rectangle is all "under" as if the check point (0,0) in my view was on the axis but above the cylinder out of the figure.

I tried to show the reference axes of the views from (project body->elenca all-> axis x ->mostra assey->mostra siz->mostra) and the reference axes of the two views are not overlapped so I am not assigning the coordinates (0,0) at the origin of the axes.

the question is therefore according to the view which point of them is the reference that assumes the coordinates given by "vista.setorigin(0,0)"?

Thank you.
the origin of sight is not said to be the center; It's almost never.

you have to calculate the 'offset' between the origin of the view and the center of the view to use it during your positioning. to calculate the center of the view you have to go to read its size.

I created a sub to place views over their center; If you can't alone I'm looking for the place
 
Okay, but the offset as the calculation? to speak more in general my purpose is to place views so that they do not overlap (the scale calculation and the check I with a proportion) but because of the problem that I said before generating the masses automatically the views go intersect often so I have to place them in a smart and just way possibly all from vba
 
then with the .getorigin method of the view you get the x and y coordinates of the origin of the view (which as said is almost never at the center of the view)

with the .range view method get x_min, y_min, x_max, y_max view.

with the calculation: x - (x_min + x_max) / 2 get view center for x axis
same thing for: y - (y_min + y_max) / 2 get the view center for the axis y

adding to these 2 values the location where you want to put the center of the view you get what you want, via the .setorigin command

I don't know if I explained?
 
ok written in vba becomes so
Code:
sub main()
    
    dim objapp as solidedgeframework.application
    dim objdft as solidedgedraft.draftdocument
    
    set objapp = getobject(, "solidedge.application")
    set objdft = objapp.activedocument
    
    dim objdv as solidedgedraft.drawingview
    set objdv = objdft.activesheet.drawingviews.item(1)

    call setcenter(objdv, 0, 0)
    
    set objdv = nothing
    set objdft = nothing
    set objapp = nothing
    
end sub

sub setcenter(objdv as solidedgedraft.drawingview, x as double, y as double)
    
    dim origine_x as double
    dim origine_y as double
    
    call objdv.getorigin(x, y)

    dim min_x as double
    dim min_y as double
    dim max_x as double
    dim max_y as double
    
    call objdv.range(min_x, min_y, max_x, max_y)
    
    call objdv.setorigin(x + origine_x - (min_x + max_x) / 2, y + origine_y - (min_y + max_y) / 2)
    
end sub
 
two questions:
1: Is it a curiosity even if everything works, when you get the extremes of the view returns the ends of the sketch or the pane around?

2: question: now I miss to position right the caption of the view like "section a-a 1:2" as the high, can you help me?
 
two questions:
1: Is it a curiosity even if everything works, when you get the extremes of the view returns the ends of the sketch or the pane around?
should be the contour
2: question: now I miss to position right the caption of the view like "section a-a 1:2" as the high, can you help me?
I've never noticed this behavior, you should go further
 
should be the contour



I've never noticed this behavior, you should go further
If you want to solve it in a way we say spice I can write a text box of ownership where I call the scale of that view? If you like it? so the posiziono fixes the label (the fact that I need to show is the value of the scale)

Thank you.
 
I just tried and the main eye caption moves along with the view.
I suggest you write everything in the main caption.

I also confirm point 1
 
I just tried and the main eye caption moves along with the view.
I suggest you write everything in the main caption.

I also confirm point 1
what you say is true but we hypothesize that I want the scale written in the cartiglio then in a "fixed textbox"
 
because we were talking about the position of the main caption of which I was particularly interested in the scale
 
should be the contour



I've never noticed this behavior, you should go further
I recall this discussion, sometimes I happen that the edge of the design view is like this:1614592576339.webppractically the view (or drawing) is not centered on the edge so when with vba center the view with the commands seen before me centered on the edge and the view goes to be blessed, there is a command like "suitable edge to the sight"? or something to solve the problem?
 
Right-click on the view "nothing cut"

Hi.
it doesn't let me do it, indeed if I move the edge by hand to adapt it to the view then I find myself "nothing cut" and brings it back to the image I put before. by default on some items makes me the edge as in the figure above and that is not centered with the view
 
it doesn't let me do it, indeed if I move the edge by hand to adapt it to the view then I find myself "nothing cut" and brings it back to the image I put before. by default on some items makes me the edge as in the figure above and that is not centered with the view
known only now that it is a section, should therefore depend on the length of the cutting line
 
what you say is true but we hypothesize that I want the scale written in the cartiglio then in a "fixed textbox"
the recall property you put in the cartiglio do not connect it to anything, there is a special text, but I do not find it
 
Good morning, I still get back to this discussion,

there is a sort of command "setrange(a,b,c,d)?
practically if with range I read the "confini" of the design view I would now set them I widen them or decreasing them.
the need to do so arises from the fact that in some cases the view that I generate in "automatic" dealing with symmetric pieces must be a sort of view interrupted, do it with the command "interrupted view" putting already the original model as an interrupted view works and it works no as from vba I can not pilot exactly the position of the interrupt line and sometimes it puts in positions where I cut things that I need.

Thank you.
 

Forum statistics

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

Members online

No members online now.
Back
Top