SketchUp已初始化常量?

我以前从未注意到这一点,但在测试我的一个插件时,我决定在加载插件。我的代码是> 我的错误信息是: c:/users/administrator/appdata/roaming/sketchup/sketchup 2017/sketchup/plugins/medeek_foundation_ext/medeek_foundation_load.rbs:39: warning: already initialized constant Medeek_Engineering_Inc_Extensions::MedeekFoundationPlugin::THIS_DIRc:/users/administrator/appdata/roaming/sketchup/sketchup 2017/sketchup/plugins/medeek_foundation_ext/medeek_foundation_load.rbs:36: warning: previous definition of THIS_DIR was here 我真的不知道这里出了什么问题,也不知道我做错了什么。我想我以前从来没有见过这个,因为我通常不显示插件load.rbz中的控制台由TIG在post#2中解决您没有做错什么。Ruby希望您只定义一次常量。当您重新分配它时,会出现一条警告消息-如您所见-但它仍然会更改。有很多方法可以在代码中重新定义一个常量来抑制错误,但是在你的情况下,为什么不重新定义一次呢,这… 您没有做错什么。 Ruby希望您只定义一次常量。 当您重新分配它时,会出现一条警告消息-如您所见-但它仍然被更改。 有一些方法可以在代码中重新定义一个常量来抑制错误,但是在您的情况下,为什么不重新定义它以只定义一次呢,> 您也可以这样做… … OR> I\"m not sure I fully understand what the double pipe or equals is doing in this case, never seen that operator before.I really do learn something every day as a developer. Ruby\"s Or Equals operator is covered in this topic https://ruby-doc.org/core-2.4.0/doc/syntax/assignment_rdoc.html#label-Abbreviated+Assignment 16 medeek: I\"m not sure I fully understand what the double pipe or equals is doing in this case Just an other source… ruby-style-guide#self-assignment 1 …andafter that ruby-style-guide#double-pipe-for-uninit 1 In this specific case this will suffice: This works all the way back to SketchUp 2014, which is quite ancient by now. Trying to support older SU versions will make the code quite a bit bulkier and uglier as it doesn\"t support a number of newer methods and idioms. EDIT: Not to mention SU API, like HtmlDialogs. In the general case I\"d use a intermediate variable and set the constant once. This is just 3 lines of code and has a single level of indentation which makes it more> I agree the three line version is more compact and more readable, I will switch out my current code… yet again. … but it won\"t suppress the warnings. The warnings are there because the Ruby core devs are heading towards true constants. Already they have implemented no dynamic constant assignment within methods. The average user is only going to load your code once, so they\"ll not likely run into the warning. It is you (the dev) who reloads your code during development that sees the warning. There are several ways to handle this so constants are loaded once. The simplest is to have all your constants in one file that is loaded the first time. Then during dev when you are tweaking things you need only reload the file that was tweaked. The other way is to use the same pattern we use to prevent multiple menu items … … ie, the first file to load: module Medeekmodule NiftyFoundationif !@loaded# define constants hereend# define methods and classes, or load other files here, etc.endend …即,要加载的最后一个文件: module Medeekmodule NiftyFoundationif !@loaded# define commands, menus and> I prefer not to clutter the code with checks if the constant is already defined. Instead the debug/test reload scrip can just hide the warnings. It\"s not very important if this is \"proper\" Ruby as it\"s never used in production, just for testing. This also has the benefit that it allows you to redefine the constants without restarting SketchUp when testing, at least for as long as Ruby supports it. # Reload extension.## @param clear_console [Boolean] Whether console should be cleared.# @param undo [Boolean] Whether last oration should be undone.## @return = nilDir.glob(File.join(PLUGIN_ROOT, \"**/*.{rb,rbe}\")).each { |f| load(f)> oh yea, a 3d way. Ruby is so multi-paradigm. def> … and then in use: quietly do# load my filesend

SketchUp在扩展仓库中更改扩展的价格不再是即时的…为什么?

我想把这个假期所有的分机都降价,但由于新分机仓库的变动,我不能降价。以前更改插件的成本非常容易,现在需要永远的时间。可以像以前那样更改吗?谢谢!现在是否需要您创建一个新草稿并再次进行审阅?办公室已在假期关闭,因此我们目前正在积压处理审阅队列。它应该很快就会恢复正常。我们正在计划清理编辑/提交过程,以便再次只有一个新的RBZ需要一个新的草稿和审阅。tt琰su:现在是否需要您创建一个新草稿并再次审阅?是的...

日期:2021-06-26 02:00:03 浏览:582

SketchUp访问组的实体以应用/更改材质

您好,据我所知,可以在组中添加实体。是否有任何方法可以访问组的特定面(例如:大小为1米、1米、1米的立方体,由6个面组成)并在每个面上应用不同的材料。谢谢这是完全可能的,尽管你需要使用的技巧取决于你对你想要的脸的了解程度油漆。一些示例:- 如果您自己创建了面,您可以立即应用材质>- 如果您知道感兴趣的面已经在组中,您可以检索它们>然后需要决定数组中的哪个面将接收哪个面材料。那个可以通过测试每个面的正常。注意grep将在组中找到所有的面孔,如果有其他人在场的话,这些面孔可能会包含比你想处理的更多的面孔我也是。...

日期:2021-06-26 05:00:05 浏览:721

SketchUp保持数值而不考虑单位

我已经开始开发一个插件,我希望输入框中的值以当前单位输入。当前如果我指定>如果模型是mm,它就可以工作,但是如果是英寸就不行。如果我只是有了相同的>如果模型是英寸而不是毫米就可以工作。有没有某种自动转换,我可以把@radius的值建立为当前的工作单位?Class:Length 1Class:Numeric 1我很欣赏文档的链接,但我已经了解了这一点,仍然不知道如何转换为当前单位。确保将默认的inputbox维度值设置为Sketchup长度。然后它将自动转换并保存为长度值(以英寸为单位)并以模型单位显示,自动...

日期:2021-06-26 06:00:03 浏览:990

SketchUp复制组/组件时出现持续的ID错误

rigin(在片段中设置)。对于你的mod,明显的旋转中心是短线的末端(右侧):这不是我的目标。这实际上使用了Sasquatch:此外,用户可以通过文本指定副本的数量(使用\"s\")供参考,所有本机工具都使用\"s\"表示边的数量,使用\"x\"表示副本的数量。明白了,按照建议从\"s\"更改为\"x\"。与此同时,我弄明白了为什么我的\"卷积\"代码产生了正确的转换,而你的代码却没有…在你的代码中,你添加每个新实例,同时对其执行转换,这只会导致相对于预选组的局部轴的转换,而是关于模型空间(或worlds...

日期:2021-06-26 07:00:04 浏览:747

SketchUpC点/引导点的样式是否可行?

我正在测试用点云做房子模型。导入点(dxf),SketchUp将其转换为许多cpoint。使用这些进行捕捉的建模很好。我的问题是:是否可以\"样式化\"cpoints?比如尺寸、颜色等?更多的视觉控制可能会更好。另外,API中是否有其他实体可以将这些CPoint转换为更小/更精细/更可定制的CPoint?通常,他们应该在渲染选项散列(样式)中采用指导色的颜色,如果\"按标记颜色\"处于禁用状态。如果\"按标记颜色\"处于启用状态,则他们将使用层/标记颜色显示。实验表明,指定材质不会使他们按材质显示。(即,指...

日期:2021-06-26 07:00:04 浏览:655

SketchUp如何获取html值

从HTML对话框获取值时出现问题。This is callback function at sketchup.add_action_callback(\"receiveValue\") { |not_used, id, val|receive_value(id,val)}def receive_value(id,>I try to get input value like this, but I can\"t get>I can\"t get dlgValues, so I checked the size...

日期:2021-06-26 12:00:03 浏览:814

SketchUp如何判断V-Ray渲染是否已完成

你好!我正在使用V-Ray自动渲染,但遇到了一个问题,即无法知道渲染何时完成。目前我渲染场景,然后等待20秒,更改模型的材质,然后再次渲染,但如果渲染在5秒内完成,这是一个非常无效的系统。到目前为止,我已经完成了尝试了live_scene.renderer?布尔值和几个VRay::Renderer::IDLE_变量,但没有成功。问题是,在从扩展渲染循环时,布尔值不会更改,因此代码总是超时,即使渲染更快完成。下面是一些示例+=1if i>20puts\"超时渲染\"BreakEndModel.commi...

日期:2021-06-26 14:00:01 浏览:1167

SketchUp rubyapi:将工具栏停靠到其他工具栏

我已经创建了自己的工具栏,但是我不知道如何将它自动停靠到行上,所有其他工具栏都已经位于行上(在下拉菜单下)。有什么提示吗?DanRathbun在post#2中解决的用户必须进行对接。您所能做的就是调用#restore。用户必须进行对接。你所能做的就是打电话给#restore4...

日期:2021-06-26 15:00:04 浏览:817

SketchUp从多个曲面创建多个组

大家晚上好,我有一张约2000个小表面的图纸,我想分组制作,然后推拉。创建曲面后,如果图形是新的,下面的脚本工作得非常好。当我只选择第二个或第三个曲面时,它仍然运行得很快,但是当我选择了一个并且在脚本中有一个以前创建的组时,它只以一半甚至更少的速度运行,脚本变成\"没有响应\",但最终在后台运行一段时间后它就完成了。即使我重新启动sketchup甚至pc并重新运行脚本,它仍然很慢。当我分解所有组并进行另一个选择时,脚本又变快了。如果我做错了什么,也许有人能告诉我。我的笔记本电脑有16 GB内存,图形卡是,并...

日期:2021-06-26 20:00:05 浏览:635

SketchUp有没有办法加快添加面和边的速度?

我正在创建一个进口商。我用实体添加面以及实体添加边导入一个模型,但是要花很多时间。54234个面需要11秒来添加面85417个边需要9秒来添加边这是一个简单的模型。对于复杂模型,创建面和边的时间太长,无法接受。我怎样才能加快速度?谢谢。您是否创建了撤消操作并在操作过程中关闭了UI?- Sketchup::Model#start_operation- Sketchup::Model#commit_operation您是否考虑过创建虚拟多边形网格…- Geom::PolygonMesh4class…然后在操作中...

日期:2021-06-27 00:00:03 浏览:852