Jump to content

How to Insert the Code to Newly created Tool??


Recommended Posts

Guest cad2007
Posted

i have created the new toolbar....Here how can i insert my codes and Commands??plz see the photoshot.....i am using cad2007 version......

New_ToolBar.JPG

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • BlackBox

    9

  • alanjt

    6

  • Lee Mac

    4

  • Tharwat

    2

Popular Days

Top Posters In This Topic

Posted Images

Posted

That was the first step .

 

So create that toolbar , and after that create a new command ( if you do not have one) and drag it on to that new toolbar .

 

That's all.

 

Tharwat

Posted

Danger, Will Robinson!

 

I would highly suggest that you not place your customizations in ACAD.cui, and instead create a new 'Custom.cui' and load that as a partial.

 

Once you've created your toolbar, create a new command, and place your code in the macro field of the new command's properties. See the Developer Documentation for more information.

 

Hope this helps!

Posted
Danger, Will Robinson!

 

I would highly suggest that you not place your customizations in ACAD.cui, and instead create a new 'Custom.cui' and load that as a partial.

 

Once you've created your toolbar, create a new command, and place your code in the macro field of the new command's properties. See the Developer Documentation for more information.

 

Hope this helps!

 

Hello Renderman.

 

Your suggestion would be a little bit diffecult and time consumption . So to ensure that your data would be in a safe side , you

could save all your customazation data to .cui file.

 

What you think ?

 

Thanks

Posted

CUI Manipulation is fairly simple, for the non-beginner.

 

It is considered a best practice to create a Custom.cui partial to prevent accidental changes within the Core CUI components (for both Main, and Enterprise CUI's). This also ensures that your customizations are easily transferable to a new software version, and/or a new employer. They're portable.

 

This process is easy, and does not take much time at all.

Guest cad2007
Posted

through code like

 

[_Button("Offset10", "XYZ", "XYZ IMAGE")]^C^C(command "offset" "10" ) is it possible

Posted
through code like

 

[_Button("Offset10", "XYZ", "XYZ IMAGE")]^C^C(command "offset" "10" ) is it possible

 

 

Ohhh... another one of those requests. :glare:

 

CUI manipulation asside... does it really save you that much time, compared to using OF+Enter and specifying the distance? :?

Posted

Another 15,000 offsets to assign to buttons? Yikes! I'm outta here.

Posted
Another 15,000 offsets to assign to buttons? Yikes! I'm outta here.

 

 

Well, to be fair, I doubt that was the OP's intended goal. :lol: lol

 

However, I think the two threads share a common flaw, trying to automate an already simple task.

 

Developer Foul #176 ... Automation for the sake of automation, and not efficiency.

Posted

I'm inclined to agree - but only partly.

 

For example, say you work in a company which draws a lot of piping, you could create your centreline, then have buttons programmed with specific offsets for the different piping diameters - saving you looking them up, or entering them incorrectly...

 

Just a thought :)

Posted
I'm inclined to agree - but only partly.

 

For example, say you work in a company which draws a lot of piping, you could create your centreline, then have buttons programmed with specific offsets for the different piping diameters - saving you looking them up, or entering them incorrectly...

 

Just a thought :)

 

 

That is a worth while thought, Lee.

 

However, the OP's macro does not include such intelligence, rather a basic predefined offset of 10 units. o:)

 

Admittedly, I have functions (not buttons) for similar purposes, tailored to my state's DOT criteria for drainage pipes (Round, Elliptical, etc.), which factor in pipe wall thickness, min and max slope, etc..

 

Working with Land Desktop (pre-Civil 3D conflict check), I developed several production tools which determine utility adjustment crossing elevations (above/below), invert elevations at specified locations, site grading utilities, as well as Utility pipe cross section automation.

 

... But again, those tools were developed for the sake of efficiency. 8)

Posted

(defun offsetCreate (low high)
 ;; Alan J. Thompson, 11.01.10
 (if (apply (function and) (mapcar (function (lambda (x) (eq (type x) 'INT))) (list low high)))
   ((lambda (i)
      (while (<= low (setq i (1+ i)) high)
        (eval (list 'defun
                    (read (strcat "c:" (itoa i)))
                    nil
                    (list 'command "_.offset" i)
                    '(princ)
              )
        )
      )
    )
     (1- low)
   )
 )
)

 

eg.

(offsetCreate 0 1000)

 

Create as many offsets as you want - ONLY WORKS WITH INTEGERS (can't have a command name 4.5).

low - lowest number

high - highest number

Posted

Pretty much a modification of yours, but perhaps to handle decimals?

 

(defun MakeOffsets ( _min _max _inc )

 (repeat (1+ (fix (/ (- _max _min) _inc)))
   (eval
     (list 'defun (read (strcat "C:" (vl-string-translate "." "," (vl-princ-to-string _min)))) nil
       (list 'command "_.offset" _min)
       (list 'princ)
     )
   )
   (setq _min (+ _min _inc))
 )

 (princ)
)

 

(MakeOffsets 3 6 0.5)

Posted

I suppose you could just supply the entire number list (be it real or integer).

(defun offsetCreate (numberList)
 (foreach x numberList
   (eval (list 'defun
               (read (strcat "c:" (vl-string-translate "." "-" (vl-princ-to-string x))))
               nil
               (list 'command "_.offset" x)
               '(princ)
         )
   )
 )
)

 

BTW Lee, I'd use a hyphen over comma since it's located on the number pad.

Posted
I suppose you could just supply the entire number list (be it real or integer).

 

Maybe... depends how many thousand they want to create...

Posted
Maybe... depends how many thousand they want to create...

Oh, I know, but it's all theoretical crap.

Posted

More fodder for the metaphorical pile...

 

(defun MakeOffsets  (_min _max _inc)
 [color=blue](vl-load-com)[/color]
 (repeat (1+ (fix (/ (- _max _min) _inc)))
   (eval
     (list
       'defun
       (read (strcat "C:"
                     (vl-string-translate
                       "."
                       ","
                       (vl-princ-to-string _min))))
       [color=blue](list '/ 'eName)[/color]
[color=blue]       (list 'if[/color]
[color=blue]             '(setq[/color]
[color=blue]               eName[/color]
[color=blue]               (car (entsel "\n Select Object to Offset:  ")))[/color]
[color=blue]             (list 'vla-offset '(vlax-ename->vla-object eName) _min))[/color]
       (list 'princ)))
   (setq _min (+ _min _inc)))
 (princ))

Posted
More fodder for the metaphorical pile...

 

(defun MakeOffsets  (_min _max _inc)
 [color=blue](vl-load-com)[/color]
 (repeat (1+ (fix (/ (- _max _min) _inc)))
   (eval
     (list
       'defun
       (read (strcat "C:"
                     (vl-string-translate
                       "."
                       ","
                       (vl-princ-to-string _min))))
       [color=blue](list '/ 'eName)[/color]
[color=blue]       (list 'if[/color]
[color=blue]             '(setq[/color]
[color=blue]               eName[/color]
[color=blue]               (car (entsel "\n Select Object to Offset:  ")))[/color]
[color=blue]             (list 'vla-offset '(vlax-ename->vla-object eName) _min))[/color]
       (list 'princ)))
   (setq _min (+ _min _inc)))
 (princ))

LoL

I hope they select valid objects and only want them offset to the perspective right.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...